*********************
*** preliminaries ***
*********************
cd "~/Dropbox/secret_ballot/replication_file/"

**************************
*** necessary packages ***
**************************
** if not already installed, the below packages must be installed
** to perform all analyses.
* ssc install binscatter /* version 7.02  24nov2013 */
* ssc install did_multiplegt /* This version: April 28th 2021 */
* ssc install csdid /* v1.56 */
* ssc install did_imputation /* Version: March 1, 2022 */
* fetrend_cluster.ado 
	/* This .ado file allows for fast computation of unit-specific trends
	with clustered standard errors. The program is available for download
	from the Fujiwara et al. (2016) replication archive:
		http://doi.org/10.3886/E113627V1
	*/


********************************
*** read in state-level data ***
********************************
use state_level_data.dta, clear

*** histograms of outcome variables ***
* FIGURE A.1
set scheme s1color
format numberofpensions_2yr tot_annual_dollars_2yr tot_po %9.0gc

hist numberofpensions_2yr, fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_countpens.pdf", replace

hist log_numberofpensions_2yr, fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_logcountpens.pdf", replace

hist tot_po, fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_countpos.pdf", replace

hist log_tot_po, fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_logcountpos.pdf", replace

hist rh_approp, fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(0(4000000)8000000,labsize(large) format(%11.0gc)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_rhapprop.pdf", replace

hist log_rh_approp, fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_logrhapprop.pdf", replace

****************
*** pensions ***
****************
local controls primary rep_pct_2party log_ipo_totpop_2yr
** TABLE 2, PANEL A
** create a table fragment for a combined/stacked table
** outcome: logged count of pensionsers
** treatment: ab
eststo clear
local pens_ab_obs ""

* state FES + year FES + NO controls
eststo: areg log_numberofpensions_2yr ab i.year if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_ab_obs = "`pens_ab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_numberofpensions_2yr ab i.year `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_ab_obs = "`pens_ab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_numberofpensions_2yr ab i.year c.year#i.state_icpsr `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_ab_obs = "`pens_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_pens_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines

** TABLE A.3, PANEL A	
** create a table fragment for a combined/stacked table
** outcome: logged pension dollars
** treatment: ab
eststo clear
local dollpen_ab_obs ""

* state FES + year FES + NO controls
eststo: areg log_tot_annual_dollars_2yr ab i.year if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local dollpen_ab_obs = "`dollpen_ab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_tot_annual_dollars_2yr ab i.year `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local dollpen_ab_obs = "`dollpen_ab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_tot_annual_dollars_2yr ab i.year c.year#i.state_icpsr `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local dollpen_ab_obs = "`dollpen_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_dollpens_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines

** TABLE A.11, PANEL A
** create a table fragment for a combined/stacked table
** outcome: logged count of pensionsers
** treatment: pc_sw ob_sw
eststo clear
local pens_pcob_obs ""

* state FES + year FES + NO controls
eststo: areg log_numberofpensions_2yr pc_sw ob_sw i.year if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_pcob_obs = "`pens_pcob_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_numberofpensions_2yr pc_sw ob_sw i.year `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_pcob_obs = "`pens_pcob_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_numberofpensions_2yr pc_sw ob_sw i.year c.year#i.state_icpsr `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_pcob_obs = "`pens_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_pens_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.15, PANEL A
** create a table fragment for a combined/stacked table
** outcome: logged count of pensionsers
** treatment: lead_ab
eststo clear
local pens_leadab_obs ""

* state FES + year FES + NO controls
eststo: areg log_numberofpensions_2yr lead_ab i.year if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_leadab_obs = "`pens_leadab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_numberofpensions_2yr lead_ab i.year `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_leadab_obs = "`pens_leadab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_numberofpensions_2yr lead_ab i.year c.year#i.state_icpsr `controls' if ///
year!=1880, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_leadab_obs = "`pens_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_pens_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.18, PANEL A
** create a table fragment for a combined/stacked table
** outcome: logged count of pensionsers
** treatment: ab
** sample restriction: exclude states in south
eststo clear
local pens_ab_nosouth_obs ""

* state FES + year FES + NO controls
eststo: areg log_numberofpensions_2yr ab i.year if ///
year!=1880 & south==0, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_ab_nosouth_obs = "`pens_ab_nosouth_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_numberofpensions_2yr ab i.year `controls' if ///
year!=1880 & south==0, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_ab_nosouth_obs = "`pens_ab_nosouth_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_numberofpensions_2yr ab i.year c.year#i.state_icpsr `controls' if ///
year!=1880 & south==0, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_ab_nosouth_obs = "`pens_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_pens_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
*** APPENDIX TABLE A.24
*** include FY1882 -- pensions
* robustness check: 
* in main analysis, we exclude FY1882 (election year 1880), as there is a gap 
* between that year and the next year with non-missing data. check if results 
* are sensitive to the the inclusion of FY1882
set more 1
eststo clear

foreach depvar of varlist log_numberofpensions_2yr log_tot_annual_dollars_2yr {
	* state FEs + year FEs
	eststo: areg `depvar' ab i.year, absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr " "
		estadd local sttrend " "
	* state FEs + year FEs + controls
	eststo: areg `depvar' ab i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend " "
	* state FEs + year FEs + controls + state-specific linear trends
	eststo: areg `depvar' ab i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend "\checkmark"
}
esttab using "tables/include82_pens.tex", replace nonotes label ///
	title("Pensions Rolls and the Australian Ballot, Including Observations FY1882" \label{pens-incl82}) noobs ///
	scalars("yrfe Year Fixed Effects" "stfe State Fixed Effects" "contr Controls" ///
	"sttrend State-Specific Trends" "N Observations") ///
	b(3) se(3) sfmt(%9.3gc) nomtitles nogaps keep(ab) star(* 0.05) varwidth(150) ///
	mgroups("ln(Pensioner Count + 1)" "ln(Pension Roll Value + 1)", pattern(1 0 0 1 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	addnotes("Robust standard errors clustered by state are in parentheses. * p $<$ 0.05." ///
			 "Dependent variable for models (1)-(3) is the log of the count of pensionsers on the roll in the" ///
			 "state, and dependent variable for models (4)-(6) is the log of the annual value (\\$) of the" ///
			 "pension roll in the state. Control variables include log population, primary election status," ///
			 "and past Republican share of the two-party presidential vote. State-specific trends are" ///
			 "state-specific linear trends.")
	
********************	 
*** post offices ***
********************
local controls primary rep_pct_2party log_ipo_totpop_2yr
** TABLE 2, PANEL B
** create a table fragment for a combined/stacked table
** outcome: logged count of post offices
** treatment: ab
eststo clear
local po_ab_obs ""
* state FES + year FES + NO controls
eststo: areg log_tot_po ab i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_ab_obs = "`po_ab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_tot_po ab i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_ab_obs = "`po_ab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_tot_po ab i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_ab_obs = "`po_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_po_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.3, PANEL B
** create a table fragment for a combined/stacked table
** outcome: po_per_capita -- count of post offices per 1,000 in population
** treatment: ab
eststo clear
local popc_ab_obs ""
* state FES + year FES + NO controls
eststo: areg po_per_capita ab i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local popc_ab_obs = "`popc_ab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg po_per_capita ab i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local popc_ab_obs = "`popc_ab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg po_per_capita ab i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local popc_ab_obs = "`popc_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_popc_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.11, PANEL B
** create a table fragment for a combined/stacked table
** outcome: logged count of post offices
** treatment: pc_sw ob_sw
eststo clear
local po_pcob_obs ""
* state FES + year FES + NO controls
eststo: areg log_tot_po pc_sw ob_sw i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_pcob_obs = "`po_pcob_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_tot_po pc_sw ob_sw i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_pcob_obs = "`po_pcob_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_tot_po pc_sw ob_sw i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_pcob_obs = "`po_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_po_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.15, PANEL B
** create a table fragment for a combined/stacked table
** outcome: logged count of post offices
** treatment: lead_ab
eststo clear
local po_leadab_obs ""
* state FES + year FES + NO controls
eststo: areg log_tot_po lead_ab i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_leadab_obs = "`po_leadab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_tot_po lead_ab i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_leadab_obs = "`po_leadab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_tot_po lead_ab i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_leadab_obs = "`po_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_po_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.18, PANEL B
** create a table fragment for a combined/stacked table
** outcome: logged count of post offices
** treatment: ab
** sample restriction: exclude states in south
eststo clear
local po_ab_nosouth_obs ""
* state FES + year FES + NO controls
eststo: areg log_tot_po ab i.year if south==0, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_ab_nosouth_obs = "`po_ab_nosouth_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_tot_po ab i.year `controls' if south==0, ///
absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_ab_nosouth_obs = "`po_ab_nosouth_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_tot_po ab i.year c.year#i.state_icpsr `controls' if south==0, ///
absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_ab_nosouth_obs = "`po_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_po_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines


*********************************
*** rivers & harbors projects ***
*********************************
local controls primary rep_pct_2party log_ipo_totpop_2yr
** TABLE 2, PANEL C
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of R&H projects
** treatment: ab
eststo clear
local rh_ab_obs ""
* state FES + year FES + NO controls
eststo: areg log_rh_approp ab i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_obs = "`rh_ab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_rh_approp ab i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_obs = "`rh_ab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_rh_approp ab i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_obs = "`rh_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rh_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.3, PANEL C
** create a table fragment for a combined/stacked table
** outcome: logged R&H project count
** treatment: ab
eststo clear
local rhproj_ab_obs ""
* state FES + year FES + NO controls
eststo: areg log_rh_projs ab i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rhproj_ab_obs = "`rhproj_ab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_rh_projs ab i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rhproj_ab_obs = "`rhproj_ab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_rh_projs ab i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rhproj_ab_obs = "`rhproj_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rhproj_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.11, PANEL C
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of R&H projects
** treatment: pc_sw ob_sw
eststo clear
local rh_pcob_obs ""
* state FES + year FES + NO controls
eststo: areg log_rh_approp pc_sw ob_sw i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pcob_obs = "`rh_pcob_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_rh_approp pc_sw ob_sw i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pcob_obs = "`rh_pcob_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_rh_approp pc_sw ob_sw i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pcob_obs = "`rh_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rh_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.15, PANEL C
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of R&H projects
** treatment: lead_ab
eststo clear
local rh_leadab_obs ""
* state FES + year FES + NO controls
eststo: areg log_rh_approp lead_ab i.year, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_leadab_obs = "`rh_leadab_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_rh_approp lead_ab i.year `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_leadab_obs = "`rh_leadab_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_rh_approp lead_ab i.year c.year#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_leadab_obs = "`rh_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rh_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.18, PANEL C
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of R&H projects
** treatment: ab
** sample restriction: exclude states in south
eststo clear
local rh_ab_nosouth_obs ""
* state FES + year FES + NO controls
eststo: areg log_rh_approp ab i.year if south==0, absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_nosouth_obs = "`rh_ab_nosouth_obs' & `temp_N'"
* state FES + year FES + controls
eststo: areg log_rh_approp ab i.year `controls' if south==0, ///
absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_nosouth_obs = "`rh_ab_nosouth_obs' & `temp_N'"
* state FES + year FES + controls + state-specific linear trends
eststo: areg log_rh_approp ab i.year c.year#i.state_icpsr `controls' if south==0, ///
absorb(state_icpsr) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_nosouth_obs = "`rh_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rh_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	

************************************************
*** poisson specifications: robustness check ***
************************************************
local controls primary rep_pct_2party log_ipo_totpop_2yr

** TABLE A.7, PANEL A
** outcome: count of pensionsers
eststo clear
local pens_pois_obs ""
* state FES + year FES + NO controls
eststo: ppmlhdfe numberofpensions_2yr ab if year!=1880, ///
a(i.year i.state_icpsr) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_pois_obs = "`pens_pois_obs' & `temp_N'"
* state FES + year FES + controls
eststo: ppmlhdfe numberofpensions_2yr ab `controls' if year!=1880, ///
a(i.year i.state_icpsr) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_pois_obs = "`pens_pois_obs' & `temp_N'"
* state FES + year FES + controls
eststo: ppmlhdfe numberofpensions_2yr ab `controls' if year!=1880, ///
a(i.year i.state_icpsr##c.year) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local pens_pois_obs = "`pens_pois_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_pens_pois.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines

** TABLE A.7, PANEL B
** outcome: count of post offices
eststo clear
local po_pois_obs ""
* state FES + year FES + NO controls
eststo: ppmlhdfe tot_po ab , ///
a(i.year i.state_icpsr) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_pois_obs = "`po_pois_obs' & `temp_N'"
* state FES + year FES + controls
eststo: ppmlhdfe tot_po ab `controls' , ///
a(i.year i.state_icpsr) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_pois_obs = "`po_pois_obs' & `temp_N'"
* state FES + year FES + controls
eststo: ppmlhdfe tot_po ab `controls' , ///
a(i.year i.state_icpsr##c.year) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local po_pois_obs = "`po_pois_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_po_pois.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines

** TABLE A.7, PANEL C
** outcome: count of rivers & harbors projects
eststo clear
local rh_pois_obs ""
* state FES + year FES + NO controls
eststo: ppmlhdfe rh_approp ab , ///
a(i.year i.state_icpsr) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pois_obs = "`rh_pois_obs' & `temp_N'"
* state FES + year FES + controls
eststo: ppmlhdfe rh_approp ab `controls' , ///
a(i.year i.state_icpsr) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pois_obs = "`rh_pois_obs' & `temp_N'"
* state FES + year FES + controls
eststo: ppmlhdfe rh_approp ab `controls' , ///
a(i.year i.state_icpsr##c.year) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pois_obs = "`rh_pois_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rh_pois.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines

	
*********************************	
*** government output indices ***
*********************************

** TABLE A.4
** create a table fragment for a combined/stacked table
** outcome: government output index
** treatment: ab
eststo clear
* state FES + year FES + NO controls
eststo: areg z_output_index ab i.year if year!=1880, absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr ""
		estadd local sttrend ""
* state FES + year FES + controls
eststo: areg z_output_index ab i.year `controls' if year!=1880, absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend ""
* state FES + year FES + controls + state-specific linear trends
eststo: areg z_output_index ab i.year c.year#i.state_icpsr `controls' if year!=1880, absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend "\checkmark"
* export table
esttab using "tables/indexout_ab.tex", replace nonotes label ///
	title("Australian Ballot \& Index of Government Outputs" \label{ab-index-outputs}) noobs ///
	scalars("yrfe Year Fixed Effects" "stfe State Fixed Effects" "contr Controls" ///
	"sttrend State-Specific Trends" "N Observations") ///
	b(3) se(3) sfmt(%9.3gc) nomtitles nogaps keep(ab) star(* 0.05) varwidth(150) ///
	addnotes("Robust standard errors clustered by state are in parentheses." ///
			 "* p $<$ 0.05. The dependent variable is an index constructed" ///
			 "from the count of pensions, count of post offices, and" ///
			 "appropriations to rivers and harbors projects. Control" ///
			 "variables include log population, primary election status," ///
			 "and past Republican share of the two-party presidential." ///
			 "vote. State-specific trends are state-specific linear trends.")
			 

*** TABLE 2
*** stacked table: pensions, post offices, rivers & harbors ***
*** outcomes: main outcomes
*** treatment: ab
*** sample restrictions: none
file open myfile using "tables/ab_outputs.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& \\ the Distribution of Federal Resources \label{ab-outputs}}" _n ///
"\begin{tabular}{l*{3}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\" _n ///
"\hline" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel A. Pensions}} \\" _n ///
"\input{tables/fragments/frag_pens_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel B. Post Offices}} \\" _n ///
"\input{tables/fragments/frag_po_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel C. Rivers \& Harbors}} \\" _n ///
"\input{tables/fragments/frag_rh_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Unit Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark \\" _n ///
"State-Specific Trends & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `pens_ab_obs' \\" _n ///
"Panel B Observations `po_ab_obs' \\" _n ///
"Panel C Observations `rh_ab_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{4}{l}{\footnotesize Robust standard errors clustered by state are in parentheses.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize * p $<$ 0.05. The dependent variable for Panel A is the logged}\\" _n ///
"\multicolumn{4}{l}{\footnotesize count of pensioners. The dependent variable for Panel B is the}\\" _n ///
"\multicolumn{4}{l}{\footnotesize logged count of post offices. The dependent variable for Panel}\\" _n ///
"\multicolumn{4}{l}{\footnotesize C is the logged appropriations to rivers and harbors projects.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize Control variables include log population, primary election}\\" _n ///
"\multicolumn{4}{l}{\footnotesize status, and past Republican share of the two-party presidential}\\" _n ///
"\multicolumn{4}{l}{\footnotesize vote. State-specific trends are state-specific linear trends.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.3
*** stacked table: pensions, post offices, rivers & harbors ***
*** outcomes: alternative outcome measures
*** treatment: ab
*** sample restrictions: none
file open myfile using "tables/altoutcome_outputs.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& \\ the Distribution of Federal Resources, \\ Alternative Outcome Measures \label{altoutcome-outputs}}" _n ///
"\begin{tabular}{l*{3}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\" _n ///
"\hline" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel A. Pensions}} \\" _n ///
"\input{tables/fragments/frag_dollpens_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel B. Post Offices}} \\" _n ///
"\input{tables/fragments/frag_popc_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel C. Rivers \& Harbors}} \\" _n ///
"\input{tables/fragments/frag_rhproj_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Unit Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark \\" _n ///
"State-Specific Trends & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `dollpen_ab_obs' \\" _n ///
"Panel B Observations `popc_ab_obs' \\" _n ///
"Panel C Observations `rhproj_ab_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{4}{l}{\footnotesize Robust standard errors clustered by state are in parentheses.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize * p $<$ 0.05. The dependent variable for Panel A is the logged}\\" _n ///
"\multicolumn{4}{l}{\footnotesize value of the pension roll. The dependent variable for Panel B}\\" _n ///
"\multicolumn{4}{l}{\footnotesize is the count of post offices per 1,000 in the population. The}\\" _n ///
"\multicolumn{4}{l}{\footnotesize dependent variable for Panel C is the logged count of rivers}\\" _n ///
"\multicolumn{4}{l}{\footnotesize and harbors projects. Control variables include log population,}\\" _n ///
"\multicolumn{4}{l}{\footnotesize primary election status, and past Republican share of the}\\" _n ///
"\multicolumn{4}{l}{\footnotesize two-party presidential vote. State-specific trends are}\\" _n ///
"\multicolumn{4}{l}{\footnotesize state-specific linear trends.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.11
*** stacked table: pensions, post offices, rivers & harbors ***
*** outcomes: main outcomes
*** treatment: pcob
*** sample restrictions: none
file open myfile using "tables/pcob_outputs.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& the \\ Distribution of Federal Resources by Ballot Type \label{pcob-outputs}}" _n ///
"\begin{tabular}{l*{3}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\" _n ///
"\hline" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel A. Pensions}} \\" _n ///
"\input{tables/fragments/frag_pens_pcob.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel B. Post Offices}} \\" _n ///
"\input{tables/fragments/frag_po_pcob.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel C. Rivers \& Harbors}} \\" _n ///
"\input{tables/fragments/frag_rh_pcob.tex}" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Unit Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark \\" _n ///
"State-Specific Trends & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `pens_pcob_obs' \\" _n ///
"Panel B Observations `po_pcob_obs' \\" _n ///
"Panel C Observations `rh_pcob_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{4}{l}{\footnotesize Robust standard errors clustered by state are in parentheses.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize * p $<$ 0.05. The dependent variable for Panel A is the logged}\\" _n ///
"\multicolumn{4}{l}{\footnotesize count of pensioners. The dependent variable for Panel B is the}\\" _n ///
"\multicolumn{4}{l}{\footnotesize logged count of post offices. The dependent variable for Panel}\\" _n ///
"\multicolumn{4}{l}{\footnotesize C is the logged appropriations to rivers and harbors projects.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize Control variables include log population, primary election}\\" _n ///
"\multicolumn{4}{l}{\footnotesize status, and past Republican share of the two-party presidential}\\" _n ///
"\multicolumn{4}{l}{\footnotesize vote. State-specific trends are state-specific linear trends.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.15
*** stacked table: pensions, post offices, rivers & harbors ***
*** outcomes: main outcomes
*** treatment: lead_ab
*** sample restrictions: none
file open myfile using "tables/leadab_outputs.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot (in Forthcoming Election) \& \\ the Distribution of Federal Resources \label{leadab-outputs}}" _n ///
"\begin{tabular}{l*{3}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\" _n ///
"\hline" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel A. Pensions}} \\" _n ///
"\input{tables/fragments/frag_pens_leadab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel B. Post Offices}} \\" _n ///
"\input{tables/fragments/frag_po_leadab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel C. Rivers \& Harbors}} \\" _n ///
"\input{tables/fragments/frag_rh_leadab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Unit Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark \\" _n ///
"State-Specific Trends & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `pens_leadab_obs' \\" _n ///
"Panel B Observations `po_leadab_obs' \\" _n ///
"Panel C Observations `rh_leadab_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{4}{l}{\footnotesize Robust standard errors clustered by state are in parentheses.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize * p $<$ 0.05. The dependent variable for Panel A is the logged}\\" _n ///
"\multicolumn{4}{l}{\footnotesize count of pensioners. The dependent variable for Panel B is the}\\" _n ///
"\multicolumn{4}{l}{\footnotesize logged count of post offices. The dependent variable for Panel}\\" _n ///
"\multicolumn{4}{l}{\footnotesize C is the logged appropriations to rivers and harbors projects.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize Control variables include log population, primary election}\\" _n ///
"\multicolumn{4}{l}{\footnotesize status, and past Republican share of the two-party presidential}\\" _n ///
"\multicolumn{4}{l}{\footnotesize vote. State-specific trends are state-specific linear trends.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.18
*** stacked table: pensions, post offices, rivers & harbors ***
*** outcomes: main outcomes
*** treatment: ab
*** sample restrictions: excluding states in the south
file open myfile using "tables/nosouth_outputs.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& \\ the Distribution of Federal Resources, \\ Excluding the South \label{nosouth-outputs}}" _n ///
"\begin{tabular}{l*{3}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\" _n ///
"\hline" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel A. Pensions}} \\" _n ///
"\input{tables/fragments/frag_pens_ab_nosouth.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel B. Post Offices}} \\" _n ///
"\input{tables/fragments/frag_po_ab_nosouth.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel C. Rivers \& Harbors}} \\" _n ///
"\input{tables/fragments/frag_rh_ab_nosouth.tex}" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"State Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark \\" _n ///
"State-Specific Trends & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `pens_ab_nosouth_obs' \\" _n ///
"Panel B Observations `po_ab_nosouth_obs' \\" _n ///
"Panel C Observations `rh_ab_nosouth_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{4}{l}{\footnotesize Robust standard errors clustered by state are in parentheses.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize * p $<$ 0.05. The dependent variable for Panel A is the logged}\\" _n ///
"\multicolumn{4}{l}{\footnotesize count of pensioners. The dependent variable for Panel B is the}\\" _n ///
"\multicolumn{4}{l}{\footnotesize logged count of post offices. The dependent variable for Panel}\\" _n ///
"\multicolumn{4}{l}{\footnotesize C is the logged appropriations to rivers and harbors projects.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize Control variables include log population, primary election}\\" _n ///
"\multicolumn{4}{l}{\footnotesize status, and past Republican share of the two-party presidential}\\" _n ///
"\multicolumn{4}{l}{\footnotesize vote. State-specific trends are state-specific linear trends.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize The South is defined as the 11 states of the former Confederacy.}\\" _n /// 
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.7
*** stacked table: pensions, post offices, rivers & harbors ***
*** outcomes: main outcomes
*** treatment: ab
*** sample restrictions: none
*** specification: poisson regression
file open myfile using "tables/pois_outputs.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{Poisson Results: \\ the Distribution of Federal Resources \label{pois-outputs}}" _n ///
"\begin{tabular}{l*{3}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\" _n ///
"\hline" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel A. Pensions}} \\" _n ///
"\input{tables/fragments/frag_pens_pois.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel B. Post Offices}} \\" _n ///
"\input{tables/fragments/frag_po_pois.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel C. Rivers \& Harbors}} \\" _n ///
"\input{tables/fragments/frag_rh_pois.tex}" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Unit Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark \\" _n ///
"State-Specific Trends & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `pens_pois_obs' \\" _n ///
"Panel B Observations `po_pois_obs' \\" _n ///
"Panel C Observations `rh_pois_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{4}{l}{\footnotesize Robust standard errors clustered by state are in parentheses.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize * p $<$ 0.05. Reported coefficients are estimated from Poisson}\\" _n ///
"\multicolumn{4}{l}{\footnotesize models. The dependent variable for Panel A is the count of}\\" _n ///
"\multicolumn{4}{l}{\footnotesize pensioners. The dependent variable for Panel B is the count of}\\" _n ///
"\multicolumn{4}{l}{\footnotesize post offices. The dependent variable for Panel C is the count}\\" _n ///
"\multicolumn{4}{l}{\footnotesize of dollars appropriated to rivers and harbors projects. Control}\\" _n ///
"\multicolumn{4}{l}{\footnotesize variables include log log population, primary election status,}\\" _n ///
"\multicolumn{4}{l}{\footnotesize and past Republican share of the two-party presidential vote.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize State-specific trends are state-specific linear trends.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile



************************************
*** staggered DiD specifications ***
************************************
preserve
bys state_abbrev ab: egen temp_min_yr_ab = min(year) if ab==1
bys state_abbrev: egen min_yr_ab = min(temp_min_yr_ab)
drop temp_min_yr_ab
gen _gvar = min_yr_ab
replace _gvar = 0 if missing(_gvar) & !missing(ab)
drop if missing(log_numberofpensions_2yr) & !inlist(year,1874,1876,1878,1882)
* create treatment variable for did_imputation command
gen _Ei = _gvar
replace _Ei = . if _gvar==0

*** pensions ***
** TABLE A.9, PANEL A
set seed 1234
local pens_did_est ""
local pens_did_se ""
local pens_did_obs ""

* TWFE, 
areg log_numberofpensions_2yr ab i.year if year!=1880, absorb(state_icpsr) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local pens_did_est = "`pens_did_est' & `temp_est'"
	local pens_did_se  = "`pens_did_se' & (`temp_se')"
	local pens_did_obs = "`pens_did_obs' & `temp_N'"
	di "`pens_did_se'"
* de Chaisemartin and D'Haultfoeuille (2020), AER
did_multiplegt  log_numberofpensions_2yr state_icpsr year ab if year!=1880, breps(250) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N_effect_0)
	local temp_est = e(effect_0)
	local temp_se = e(se_effect_0)
	local temp_t = abs(`temp_est' / `temp_se')
	local temp_est : di %9.3fc e(effect_0)
	local temp_se : di %9.3fc e(se_effect_0)
	local temp_se = strtrim("`temp_se'")
		if `temp_t' > 1.96 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local pens_did_est = "`pens_did_est' & `temp_est'"
	local pens_did_se  = "`pens_did_se' & (`temp_se')"
	local pens_did_obs = "`pens_did_obs' & `temp_N'"
* Callaway and Sant'Anna (2021)
csdid log_numberofpensions_2yr if year!=1880, ivar(state_icpsr) time(year) gvar(_gvar) agg(simple)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local pens_did_est = "`pens_did_est' & `temp_est'"
	local pens_did_se  = "`pens_did_se' & (`temp_se')"
	local pens_did_obs = "`pens_did_obs' & `temp_N'"
*  Borusyak, Jaravel, and Spiess (2022)
did_imputation log_numberofpensions_2yr state_icpsr year _Ei if year!=1880, autosample cluster(state_icpsr) maxit(500)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}	
	local pens_did_est = "`pens_did_est' & `temp_est'"
	local pens_did_se  = "`pens_did_se' & (`temp_se')"
	local pens_did_obs = "`pens_did_obs' & `temp_N'"

file open myfile using "tables/fragments/frag_pens_did.tex", write replace
file write myfile ///
"Treatment Effect `pens_did_est' \\" _n ///
"`pens_did_se' \\" _n
file close myfile

*** post offices ***
** TABLE A.9, PANEL B
set seed 1234
local po_did_est ""
local po_did_se ""
local po_did_obs ""

* TWFE, 
areg log_tot_po ab i.year, absorb(state_icpsr) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local po_did_est = "`po_did_est' & `temp_est'"
	local po_did_se  = "`po_did_se' & (`temp_se')"
	local po_did_obs = "`po_did_obs' & `temp_N'"
* de Chaisemartin and D'Haultfoeuille (2020), AER
did_multiplegt  log_tot_po state_icpsr year ab, breps(250) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N_effect_0)
	local temp_est = e(effect_0)
	local temp_se = e(se_effect_0)
	local temp_t = abs(`temp_est' / `temp_se')
	local temp_est : di %9.3fc e(effect_0)
	local temp_se : di %9.3fc e(se_effect_0)
	local temp_se = strtrim("`temp_se'")
		if `temp_t' > 1.96 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local po_did_est = "`po_did_est' & `temp_est'"
	local po_did_se  = "`po_did_se' & (`temp_se')"
	local po_did_obs = "`po_did_obs' & `temp_N'"
* Callaway and Sant'Anna (2021)
csdid log_tot_po, ivar(state_icpsr) time(year) gvar(_gvar) agg(simple)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local po_did_est = "`po_did_est' & `temp_est'"
	local po_did_se  = "`po_did_se' & (`temp_se')"
	local po_did_obs = "`po_did_obs' & `temp_N'"
*  Borusyak, Jaravel, and Spiess (2022)
did_imputation log_tot_po state_icpsr year _Ei, autosample cluster(state_icpsr) maxit(500)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}	
	local po_did_est = "`po_did_est' & `temp_est'"
	local po_did_se  = "`po_did_se' & (`temp_se')"
	local po_did_obs = "`po_did_obs' & `temp_N'"

file open myfile using "tables/fragments/frag_po_did.tex", write replace
file write myfile ///
"Treatment Effect `po_did_est' \\" _n ///
"`po_did_se' \\" _n
file close myfile

*** rivers and harbors ***
** TABLE A.9, PANEL C
set seed 1234
local rh_did_est ""
local rh_did_se ""
local rh_did_obs ""

* TWFE, 
areg log_rh_approp ab i.year, absorb(state_icpsr) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local rh_did_est = "`rh_did_est' & `temp_est'"
	local rh_did_se  = "`rh_did_se' & (`temp_se')"
	local rh_did_obs = "`rh_did_obs' & `temp_N'"
* de Chaisemartin and D'Haultfoeuille (2020), AER
did_multiplegt  log_rh_approp state_icpsr year ab, breps(250) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N_effect_0)
	local temp_est = e(effect_0)
	local temp_se = e(se_effect_0)
	local temp_t = abs(`temp_est' / `temp_se')
	local temp_est : di %9.3fc e(effect_0)
	local temp_se : di %9.3fc e(se_effect_0)
	local temp_se = strtrim("`temp_se'")
		if `temp_t' > 1.96 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local rh_did_est = "`rh_did_est' & `temp_est'"
	local rh_did_se  = "`rh_did_se' & (`temp_se')"
	local rh_did_obs = "`rh_did_obs' & `temp_N'"
* Callaway and Sant'Anna (2021)
csdid log_rh_approp, ivar(state_icpsr) time(year) gvar(_gvar) agg(simple)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local rh_did_est = "`rh_did_est' & `temp_est'"
	local rh_did_se  = "`rh_did_se' & (`temp_se')"
	local rh_did_obs = "`rh_did_obs' & `temp_N'"
*  Borusyak, Jaravel, and Spiess (2022)
did_imputation log_rh_approp state_icpsr year _Ei, autosample cluster(state_icpsr) maxit(500)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}	
	local rh_did_est = "`rh_did_est' & `temp_est'"
	local rh_did_se  = "`rh_did_se' & (`temp_se')"
	local rh_did_obs = "`rh_did_obs' & `temp_N'"


file open myfile using "tables/fragments/frag_rh_did.tex", write replace
file write myfile ///
"Treatment Effect `rh_did_est' \\" _n ///
"`rh_did_se' \\" _n
file close myfile

** TABLE A.9
file open myfile using "tables/did_outputs.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Government Outputs -- Alternative DiD Methods \label{did-outputs}}" _n ///
"\begin{tabular}{l*{8}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} \\" _n ///
"\hline" _n ///
"\multicolumn{5}{l}{} \\[-2ex]" _n ///
"\multicolumn{5}{l}{\textit{Panel A. Pensions}} \\" _n ///
"\input{tables/fragments/frag_pens_did.tex}" _n ///
"\multicolumn{5}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{5}{l}{\textit{Panel B. Post Offices}} \\" _n ///
"\input{tables/fragments/frag_po_did.tex}" _n ///
"\multicolumn{5}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{5}{l}{\textit{Panel C. Rivers \& Harbors}} \\" _n ///
"\input{tables/fragments/frag_rh_did.tex}" _n ///
"\multicolumn{5}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Method & TWFE & dC-DH & C-S & B-J-S \\" _n ///
"Unit & State & State & State & State \\" _n ///
"\hline" _n ///
"Panel A Obs. `pens_did_obs' \\" _n ///
"Panel B Obs. `po_did_obs' \\" _n ///
"Panel C Obs. `rh_did_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{5}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05.}\\" _n ///
"\multicolumn{5}{l}{\footnotesize The dependent variable for Panel A is the logged count of pensioners.}\\" _n ///
"\multicolumn{5}{l}{\footnotesize The dependent variable for Panel B is the logged count of post }\\" _n ///
"\multicolumn{5}{l}{\footnotesize offices. The dependent variable for Panel C is the logged}\\" _n ///
"\multicolumn{5}{l}{\footnotesize appropriations to rivers and harbors projects. No control variables}\\" _n ///
"\multicolumn{5}{l}{\footnotesize  are included in any specification.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

restore

****************************
*** plot of (pre-)trends ***
****************************

* create treatment/control states based on year of adoption
bys state_abbrev ab: egen temp_min_yr_ab = min(year) if ab==1
bys state_abbrev: egen min_yr_ab = min(temp_min_yr_ab)
drop temp_min_yr_ab

gen group_min_yr_ab = "1888-1890" if min_yr_ab<=1890
replace group_min_yr_ab = "1891-1893" if min_yr_ab>=1891 & min_yr_ab<=1893
replace group_min_yr_ab = "1894-1896" if min_yr_ab>=1894 & min_yr_ab<=1896
replace group_min_yr_ab = "post-1896" if min_yr_ab>1896

set scheme s1color

* FIGURE A.2 (a)
* log count of pensionsers: plot pre-trends by group 
* (exclude territories that became states during the period)
binscatter log_numberofpensions_2yr year if year>=1884 & year<=1908 & ///
	!inlist(state_abbrev,"SD","ND","MT","WA","ID","WY"), ///
	msymbols(O T S D) col(navy maroon dkgreen dkorange) plotregion(lw(0)) ///
	by(group_min_yr_ab) discrete line(connect) legend(off) ///
	text(9.55 1898 "1888-1890", place(c) col(navy) size(large)) ///
	text(9.83 1898 "1891-1893", place(c) col(maroon) size(large)) ///
	text(9.1 1898 "1894-1896", place(c) col(dkgreen) size(large)) ///
	text(8.75 1898 "Post-1896", place(c) col(dkorange) size(large)) ///
	xlabel(1884(4)1908,labsize(large)) xtitle("Election Year", size(large)) ///
	ytitle("ln(Pensioner Count + 1)", size(large)) ///
	ylabel(7.5(.5)10,angle(horizontal) labsize(large)) xsize(8) ysize(6) 
graph export "figs/pretrends_countpens.pdf", replace

* FIGURE A.2 (b)
* log count of post offices: plot pre-trends by group 
* (exclude territories that became states during the period)
binscatter log_tot_po year if year>=1876 & year<=1908 & ///
	!inlist(state_abbrev,"SD","ND","MT","WA","ID","WY"), ///
	msymbols(O T S D) col(navy maroon dkgreen dkorange) plotregion(lw(0)) ///
	by(group_min_yr_ab) discrete line(connect) legend(off) ///
	text(6.7 1895 "1888-1890", place(c) col(navy) size(large)) ///
	text(7.03 1893 "1891-1893", place(c) col(maroon) size(large)) ///
	text(7.35 1882 "1894-1896", place(c) col(dkgreen) size(large)) ///
	text(7.2 1888.4 "Post-1896", place(e) col(dkorange) size(large)) ///
	xlabel(1876(4)1908,labsize(large)) ///
	xtitle("Election Year",size(large)) ytitle("ln(Count of Post Offices + 1)",size(large)) ///
	ylabel(6.25(.25)7.5,angle(horizontal) labsize(large)) xsize(8) ysize(6)
graph export "figs/pretrends_countpos.pdf", replace

* FIGURE A.2 (c)
* log count of R&H appropriations: plot pre-trends by group 
* (exclude territories that became states during the period)
binscatter log_rh_approp year if year<=1908 & ///
	!inlist(state_abbrev,"SD","ND","MT","WA","ID","WY"), ///
	msymbols(O T S D) col(navy maroon dkgreen dkorange) plotregion(lw(0)) ///
	by(group_min_yr_ab) discrete line(connect) legend(off) ///
	text(12.8 1890 "1888-1890", place(c) col(navy) size(large)) ///
	text(11.5 1890 "1891-1893", place(c) col(maroon) size(large)) ///
	text(10 1901.6 "1894-1896", place(w) col(dkgreen) size(large)) ///
	text(13.8 1902 "Post-1896", place(c) col(dkorange) size(large)) ///
	xlabel(1888(4)1908,labsize(large)) xtitle("Election Year", size(large)) ///
	ytitle("ln(Appropriations + 1)", size(large)) ///
	ylabel(10(1)15,angle(horizontal) labsize(large)) xsize(8) ysize(6)
graph export "figs/pretrends_rhapprop.pdf", replace


**********************************
*** media environment analysis ***
**********************************
local controls primary rep_pct_2party log_ipo_totpop
eststo clear

* TABLE A.25
* candidate and log candidate mentions
foreach depvar of varlist candidate_hits ln_candidate_hits {
	* state FEs + year FEs 
	eststo: areg `depvar' ab i.fiscalyear, absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr " "
		estadd local sttrend " "
	* state FEs + year FEs + controls
	eststo: areg `depvar' ab i.fiscalyear `controls', absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend " "
	* state FEs + year FEs + controls + state-specific linear trends
	eststo: areg `depvar' ab i.fiscalyear c.fiscalyear#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend "\checkmark"
}
esttab using "tables/main_news.tex", replace nonotes label ///
	title("Candidate Newspaper Coverage and the Australian Ballot" \label{main-news}) noobs ///
	scalars("yrfe Year Fixed Effects" "stfe State Fixed Effects" "contr Controls" ///
	"sttrend State-Specific Trends" "N Observations") ///
	b(3) se(3) sfmt(%9.3gc) nomtitles nogaps keep(ab) star(* 0.05) varwidth(150) ///
	mgroups("Candidate Mentions" "ln(Candidate Mentions + 1)", pattern(1 0 0 1 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	addnotes("Robust standard errors clustered by state are in parentheses. * p $<$ 0.05." ///
			 "Dependent variable for models (1)-(3) is the number of news stories in the state, and dependent variable " ///
			 "for models (4)-(6) is the logged number of news stories in the state. Control variables include" ///
			 "log population, primary election status, and past Republican share of the two-party presidential vote." ///
			 "State-specific trends are state-specific linear trends.")

* TABLE A.26
* relative candidate mentions
eststo clear
foreach depvar of varlist pct_candidate ln_pct_candidate {
	* state FEs + year FEs 
	eststo: areg `depvar' ab i.fiscalyear, absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr " "
		estadd local sttrend " "
	* state FEs + year FEs + controls
	eststo: areg `depvar' ab i.fiscalyear `controls', absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend " "
	* state FEs + year FEs + controls + state-specific linear trends
	eststo: areg `depvar' ab i.fiscalyear c.fiscalyear#i.state_icpsr `controls', absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local yrfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend "\checkmark"
}
esttab using "tables/relative_news.tex", replace nonotes label ///
	title("Relative Candidate Newspaper Coverage and the Australian Ballot" \label{relative-news}) noobs ///
	scalars("yrfe Year Fixed Effects" "stfe State Fixed Effects" "contr Controls" ///
	"sttrend State-Specific Trends" "N Observations") ///
	b(3) se(3) sfmt(%9.3gc) nomtitles nogaps keep(ab) star(* 0.05) varwidth(150) ///
	mgroups("Percent Mentions" "ln(Percent Mentions + 1)", pattern(1 0 0 1 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	addnotes("Robust standard errors clustered by state are in parentheses. * p $<$ 0.05." ///
			 "Dependent variable for models (1)-(3) is the percentage of news stories on political candidates" ///
			 "out of total stories on candidates and parties. The dependent variable for models (4)-(6)" ///
			 "is the logged value of this quantity plus one. Control variables include log population," ///
			 "primary election status, and past Republican share of the two-party presidential vote." ///
			 "State-specific trends are state-specific linear trends.")

			 
			 
***********************************
***********************************
*** read in district-level data ***
***********************************
***********************************
use district_level_data.dta, clear


************************
*** rivers & harbors ***
************************

local controls primary margin chr_any hsemaj_r republican hse_terms ///
	com_pens com_pinv com_clms com_maff com_naff com_cmrc com_iaff com_bild ///
	com_land com_judi com_rhar com_agri com_bank com_educ com_faff ///
	com_imig com_labo com_ways
local cond if flag_mult_mc!=1 & dist<98 

** TABLE A.21, PANEL A
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of rivers & harbors projects
** treatment: ab
set more 1
eststo clear
local rh_ab_obs ""

* district FEs + cong FEs + NO controls
eststo: areg log_rh_approp ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_obs = "`rh_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_rh_approp ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_obs = "`rh_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_rh_approp ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rh_ab_obs = "`rh_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_dist_rh_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.21, PANEL B
** create a table fragment for a combined/stacked table
** outcome: logged count of r&h projects
** treatment: ab
set more 1
eststo clear
local rhproj_ab_obs ""

* district FEs + cong FEs + NO controls
eststo: areg log_rh_projs ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rhproj_ab_obs = "`rhproj_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_rh_projs ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rhproj_ab_obs = "`rhproj_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_rh_projs ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rhproj_ab_obs = "`rhproj_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_dist_rhproj_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.21, PANEL C	
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of rivers & harbors projects
** treatment: pc_sw ob_sw
set more 1
eststo clear
local rh_pcob_obs ""

* district FEs + cong FEs + NO controls
eststo: areg log_rh_approp pc_sw ob_sw i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pcob_obs = "`rh_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_rh_approp pc_sw ob_sw i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_pcob_obs = "`rh_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_rh_approp pc_sw ob_sw cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rh_pcob_obs = "`rh_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_dist_rh_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.21, PANEL D	
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of rivers & harbors projects
** treatment: lead_ab
set more 1
eststo clear
local rh_leadab_obs ""

* district FEs + cong FEs + NO controls
eststo: areg log_rh_approp lead_ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_leadab_obs = "`rh_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_rh_approp lead_ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_leadab_obs = "`rh_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_rh_approp lead_ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rh_leadab_obs = "`rh_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_dist_rh_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.21, PANEL E	
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of rivers & harbors projects
** treatment: ab
** sample restriction: exclude states in the south
set more 1
eststo clear
local rh_ab_nosouth_obs ""

* district FEs + cong FEs + NO controls
eststo: areg log_rh_approp ab i.congress `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_nosouth_obs = "`rh_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_rh_approp ab i.congress `controls' `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_nosouth_obs = "`rh_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_rh_approp ab cong_* `controls' `cond' & south==0, i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rh_ab_nosouth_obs = "`rh_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_dist_rh_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.21, PANEL F
** create a table fragment for a combined/stacked table
** outcome: logged appropriations of rivers & harbors projects
** treatment: ab
set more 1
eststo clear
local rhpapprop_ab_membfe_obs ""

* district FEs + cong FEs + NO controls
eststo: areg log_rh_approp ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_membfe_obs = "`rh_ab_membfe_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_rh_approp ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rh_ab_membfe_obs = "`rh_ab_membfe_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_rh_approp ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rh_ab_membfe_obs = "`rh_ab_membfe_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_dist_rh_ab_membfe.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines


*** TABLE A.21
*** stacked table: district-level rivers & harbors ***
*** outcomes: main outcomes
*** treatment: ab
*** sample restrictions: none
file open myfile using "tables/rh_district.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{Rivers \& Harbors Projects, \\ District-Level Analysis \label{rh-district}}" _n ///
"\begin{tabular}{l*{3}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\" _n ///
"\hline" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel A. Main Specification: Logged Appropriations}} \\" _n ///
"\input{tables/fragments/frag_dist_rh_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel B. Alternative Outcome: Logged Project Count}} \\" _n ///
"\input{tables/fragments/frag_dist_rhproj_ab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel C. Decomposing by Ballot Type}} \\" _n ///
"\input{tables/fragments/frag_dist_rh_pcob.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel D. Anticipatory Legislator Behavior}} \\" _n ///
"\input{tables/fragments/frag_dist_rh_leadab.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel E. Excluding States in the South}} \\" _n ///
"\input{tables/fragments/frag_dist_rh_ab_nosouth.tex}" _n ///
"\multicolumn{4}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{4}{l}{\textit{Panel F. Member Fixed Effects}} \\" _n ///
"\input{tables/fragments/frag_dist_rh_ab_membfe.tex}" _n ///
"\multicolumn{4}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \\" _n ///
"Member Fixed Effects & & & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark \\" _n ///
"Unit-Specific Trends & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `rh_ab_obs' \\" _n ///
"Panel B Observations `rhproj_ab_obs' \\" _n ///
"Panel C Observations `rh_pcob_obs' \\" _n ///
"Panel D Observations `rh_leadab_obs' \\" _n ///
"Panel E Observations `rh_ab_nosouth_obs' \\" _n ///
"Panel F Observations `rh_ab_membfe_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{4}{l}{\footnotesize Robust standard errors clustered by state are in parentheses.}\\" _n ///
"\multicolumn{4}{l}{\footnotesize * p $<$ 0.05. The dependent variable for Panels A, C, D, E,}\\" _n ///
"\multicolumn{4}{l}{\footnotesize and F is the logged count of rivers and harbors projects. The}\\" _n ///
"\multicolumn{4}{l}{\footnotesize dependent variable for Panel B is the logged rivers and harbors}\\" _n ///
"\multicolumn{4}{l}{\footnotesize appropriations. Unit-specific trends are district-specific}\\" _n ///
"\multicolumn{4}{l}{\footnotesize linear trends for Panels A-E and member-specific linear trends}\\" _n ///
"\multicolumn{4}{l}{\footnotesize for Panel F.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile


************************
*** bill sponsorship ***
************************
set more 1
local controls primary margin chr_any hsemaj_r republican hse_terms ///
	com_pens com_pinv com_clms com_maff com_naff com_cmrc com_iaff com_bild ///
	com_land com_judi com_rhar com_agri com_bank com_educ com_faff ///
	com_imig com_labo com_ways
local cond if flag_mult_mc!=1 & dist<98 

** TABLE 3, PANEL A
** create a table fragment for a combined/stacked table
** outcome: logged count of private bills sponsored
** treatment: ab
eststo clear
local priv_ab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_private ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_obs = "`priv_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_private ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_obs = "`priv_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_ab_obs = "`priv_ab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_private ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_obs = "`priv_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_private ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_obs = "`priv_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_ab_obs = "`priv_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_priv_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.12, PANEL A	
** create a table fragment for a combined/stacked table
** outcome: logged count of private bills sponsored
** treatment: pc_sw ob_sw
eststo clear
local priv_pcob_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_private pc_sw ob_sw i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pcob_obs = "`priv_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_private pc_sw ob_sw i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pcob_obs = "`priv_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private pc_sw ob_sw cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_pcob_obs = "`priv_pcob_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_private pc_sw ob_sw i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pcob_obs = "`priv_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_private pc_sw ob_sw i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pcob_obs = "`priv_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private pc_sw ob_sw cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_pcob_obs = "`priv_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_priv_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.16, PANEL A	
** create a table fragment for a combined/stacked table
** outcome: logged count of private bills sponsored
** treatment: lead_ab
eststo clear
local priv_leadab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_private lead_ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_leadab_obs = "`priv_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_private lead_ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_leadab_obs = "`priv_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private lead_ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_leadab_obs = "`priv_leadab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_private lead_ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_leadab_obs = "`priv_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_private lead_ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_leadab_obs = "`priv_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private lead_ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_leadab_obs = "`priv_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_priv_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.19, PANEL A	
** create a table fragment for a combined/stacked table
** outcome: logged count of private bills sponsored
** treatment: ab
** sample restriction: exclude states in the south
eststo clear
local priv_ab_nosouth_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_private ab i.congress `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_nosouth_obs = "`priv_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_private ab i.congress `controls' `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_nosouth_obs = "`priv_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private ab cong_* `controls' `cond' & south==0, i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_ab_nosouth_obs = "`priv_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_private ab i.congress `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_nosouth_obs = "`priv_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_private ab i.congress `controls' `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_nosouth_obs = "`priv_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private ab cong_* `controls' `cond' & south==0, i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_ab_nosouth_obs = "`priv_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_priv_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.14, PANEL A
** create a table fragment for a combined/stacked table
** outcome: logged count of private bills sponsored
** treatment: ab
** estimated separately by party
eststo clear
local priv_ab_party_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_private ab ab_republican republican i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_party_obs = "`priv_ab_party_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_private ab ab_republican i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_party_obs = "`priv_ab_party_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private ab ab_republican cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_ab_party_obs = "`priv_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_private ab ab_republican republican i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_party_obs = "`priv_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_private ab ab_republican i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_ab_party_obs = "`priv_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_private ab ab_republican cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local priv_ab_party_obs = "`priv_ab_party_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_priv_ab_party.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab*) star(* 0.05) nolines
	

	
************************************
*** roll-call participation rate ***
************************************
set more 1
local controls primary margin chr_any hsemaj_r republican hse_terms ///
	com_pens com_pinv com_clms com_maff com_naff com_cmrc com_iaff com_bild ///
	com_land com_judi com_rhar com_agri com_bank com_educ com_faff ///
	com_imig com_labo com_ways
local cond if flag_mult_mc!=1 & dist<98 & _merge_fino==3

** TABLE 3, PANEL B	
** create a table fragment for a combined/stacked table
** outcome: roll-call participation rate
** treatment: ab
eststo clear
local rcpart_ab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg rc_part_rate ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_obs = "`rcpart_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg rc_part_rate ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_obs = "`rcpart_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_obs = "`rcpart_ab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg rc_part_rate ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_obs = "`rcpart_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg rc_part_rate ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_obs = "`rcpart_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_obs = "`rcpart_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rcpart_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.12, PANEL B
** create a table fragment for a combined/stacked table
** outcome: roll-call participation rate
** treatment: pc_sw ob_sw
eststo clear
local rcpart_pcob_obs ""
* district FEs + cong FEs + NO controls
eststo: areg rc_part_rate pc_sw ob_sw i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_pcob_obs = "`rcpart_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg rc_part_rate pc_sw ob_sw i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_pcob_obs = "`rcpart_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate pc_sw ob_sw cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_pcob_obs = "`rcpart_pcob_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg rc_part_rate pc_sw ob_sw i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_pcob_obs = "`rcpart_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg rc_part_rate pc_sw ob_sw i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_pcob_obs = "`rcpart_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate pc_sw ob_sw cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_pcob_obs = "`rcpart_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rcpart_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.16, PANEL B	
** create a table fragment for a combined/stacked table
** outcome: roll-call participation rate
** treatment: lead_ab
eststo clear
local rcpart_leadab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg rc_part_rate lead_ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_leadab_obs = "`rcpart_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg rc_part_rate lead_ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_leadab_obs = "`rcpart_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate lead_ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_leadab_obs = "`rcpart_leadab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg rc_part_rate lead_ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_leadab_obs = "`rcpart_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg rc_part_rate lead_ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_leadab_obs = "`rcpart_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate lead_ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_leadab_obs = "`rcpart_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rcpart_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.19, PANEL B	
** create a table fragment for a combined/stacked table
** outcome: roll-call participation rate
** treatment: ab
** sample restriction: exclude states in the south
eststo clear
local rcpart_ab_nosouth_obs ""
* district FEs + cong FEs + NO controls
eststo: areg rc_part_rate ab i.congress `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_nosouth_obs = "`rcpart_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg rc_part_rate ab i.congress `controls' `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_nosouth_obs = "`rcpart_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate ab cong_* `controls' `cond' & south==0, i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_nosouth_obs = "`rcpart_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg rc_part_rate ab i.congress `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_nosouth_obs = "`rcpart_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg rc_part_rate ab i.congress `controls' `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_nosouth_obs = "`rcpart_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate ab cong_* `controls' `cond' & south==0, i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_nosouth_obs = "`rcpart_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rcpart_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.14, PANEL B
** create a table fragment for a combined/stacked table
** outcome: roll-call participation rate
** treatment: ab
** separately by party
eststo clear
local rcpart_ab_party_obs ""
* district FEs + cong FEs + NO controls
eststo: areg rc_part_rate ab ab_republican republican i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_party_obs = "`rcpart_ab_party_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg rc_part_rate ab ab_republican i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_party_obs = "`rcpart_ab_party_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate ab ab_republican cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_party_obs = "`rcpart_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg rc_part_rate ab ab_republican republican i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_party_obs = "`rcpart_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg rc_part_rate ab ab_republican i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_party_obs = "`rcpart_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster rc_part_rate ab ab_republican cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local rcpart_ab_party_obs = "`rcpart_ab_party_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_rcpart_ab_party.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab*) star(* 0.05) nolines
	

****************
*** speeches ***
****************
set more 1
local controls primary margin chr_any hsemaj_r republican hse_terms ///
	com_pens com_pinv com_clms com_maff com_naff com_cmrc com_iaff com_bild ///
	com_land com_judi com_rhar com_agri com_bank com_educ com_faff ///
	com_imig com_labo com_ways
local cond if flag_mult_mc!=1 & dist<98 & _merge_fino==3

** TABLE 3, PANEL C
** create a table fragment for a combined/stacked table
** outcome: log speeches
** treatment: ab
eststo clear
local speech_ab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_speeches ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_obs = "`speech_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_speeches ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_obs = "`speech_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_ab_obs = "`speech_ab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_speeches ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_obs = "`speech_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_speeches ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_obs = "`speech_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_ab_obs = "`speech_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_speech_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.12, PANEL C
** create a table fragment for a combined/stacked table
** outcome: log speeches
** treatment: pc_sw ob_sw
eststo clear
local speech_pcob_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_speeches pc_sw ob_sw i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pcob_obs = "`speech_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_speeches pc_sw ob_sw i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pcob_obs = "`speech_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches pc_sw ob_sw cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_pcob_obs = "`speech_pcob_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_speeches pc_sw ob_sw i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pcob_obs = "`speech_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_speeches pc_sw ob_sw i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pcob_obs = "`speech_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches pc_sw ob_sw cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_pcob_obs = "`speech_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_speech_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.16, PANEL C	
** create a table fragment for a combined/stacked table
** outcome: log speeches
** treatment: lead_ab
eststo clear
local speech_leadab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_speeches lead_ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_leadab_obs = "`speech_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_speeches lead_ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_leadab_obs = "`speech_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches lead_ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_leadab_obs = "`speech_leadab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_speeches lead_ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_leadab_obs = "`speech_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_speeches lead_ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_leadab_obs = "`speech_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches lead_ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_leadab_obs = "`speech_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_speech_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.19, PANEL C	
** create a table fragment for a combined/stacked table
** outcome: log speeches
** treatment: ab
** sample restriction: exclude states in the south
eststo clear
local speech_ab_nosouth_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_speeches ab i.congress `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_nosouth_obs = "`speech_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_speeches ab i.congress `controls' `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_nosouth_obs = "`speech_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches ab cong_* `controls' `cond' & south==0, i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_ab_nosouth_obs = "`speech_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_speeches ab i.congress `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_nosouth_obs = "`speech_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_speeches ab i.congress `controls' `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_nosouth_obs = "`speech_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches ab cong_* `controls' `cond' & south==0, i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_ab_nosouth_obs = "`speech_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_speech_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.14, PANEL C	
** create a table fragment for a combined/stacked table
** outcome: log speeches
** treatment: ab
** separately by party
eststo clear
local speech_ab_party_obs ""
* district FEs + cong FEs + NO controls
eststo: areg log_speeches ab ab_republican republican i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_party_obs = "`speech_ab_party_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg log_speeches ab ab_republican i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_party_obs = "`speech_ab_party_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches ab ab_republican cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_ab_party_obs = "`speech_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg log_speeches ab ab_republican republican i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_party_obs = "`speech_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg log_speeches ab ab_republican i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_ab_party_obs = "`speech_ab_party_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster log_speeches ab ab_republican cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local speech_ab_party_obs = "`speech_ab_party_obs' & `temp_N'"
	test ab + ab_republican = 0 
* fragment of table
esttab using "tables/fragments/frag_speech_ab_party.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab*) star(* 0.05) nolines
	

************************************************
*** poisson specifications: robustness check ***
************************************************

** TABLE A.8, PANEL A
** create a table fragment for a combined/stacked table
** outcome: count of private bills sponsored
** treatment: ab
eststo clear
local priv_pois_obs ""
* district FEs + cong FEs + NO controls
eststo: ppmlhdfe private ab `cond', a(i.congress i._dist_id) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pois_obs = "`priv_pois_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: ppmlhdfe private ab `controls' `cond', a(i.congress i._dist_id) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pois_obs = "`priv_pois_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: ppmlhdfe private ab cong_* `controls' `cond', a(i.congress i._dist_id##c.congress) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pois_obs = "`priv_pois_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: ppmlhdfe private ab i.congress `cond', a(i.congress i.icpsrno) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pois_obs = "`priv_pois_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: ppmlhdfe private ab i.congress `controls' `cond', a(i.congress i.icpsrno) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pois_obs = "`priv_pois_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: ppmlhdfe private ab cong_* `controls' `cond', a(i.congress i.icpsrno##c.congress) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local priv_pois_obs = "`priv_pois_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_priv_pois.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.8, PANEL B
** outcome: count of speeches
** treatment: ab
eststo clear
local speech_pois_obs ""
* district FEs + cong FEs + NO controls
eststo: ppmlhdfe n_speech200words ab i.congress `cond', a(i.congress i._dist_id) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pois_obs = "`speech_pois_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: ppmlhdfe n_speech200words ab i.congress `controls' `cond', a(i.congress i._dist_id) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pois_obs = "`speech_pois_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: ppmlhdfe n_speech200words ab cong_* `controls' `cond', a(i.congress i._dist_id##c.congress) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pois_obs = "`speech_pois_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: ppmlhdfe n_speech200words ab i.congress `cond', a(i.congress i.icpsrno) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pois_obs = "`speech_pois_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: ppmlhdfe n_speech200words ab i.congress `controls' `cond', a(i.congress i.icpsrno) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pois_obs = "`speech_pois_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: ppmlhdfe n_speech200words ab cong_* `controls' `cond', a(i.congress i.icpsrno##c.congress) vce(cluster state_icpsr)
	local temp_N : di %9.0fc e(N)
	local speech_pois_obs = "`speech_pois_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_speech_pois.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines


*******************************
*** legislator effort index ***
*******************************
** TABLE A.5
** create a table fragment for a combined/stacked table
** outcome: index of legislator effort
** treatment: ab
eststo clear
local index_effort_ab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg z_effort_index ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
		estadd local yrfe "\checkmark"
		estadd local distfe "\checkmark"
		estadd local membfe ""
		estadd local contr ""
		estadd local sttrend ""
* district FEs + cong FEs + controls
eststo: areg z_effort_index ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
		estadd local yrfe "\checkmark"
		estadd local distfe "\checkmark"
		estadd local membfe ""
		estadd local contr "\checkmark"
		estadd local sttrend ""
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster z_effort_index ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
		estadd local yrfe "\checkmark"
		estadd local distfe "\checkmark"
		estadd local membfe ""
		estadd local contr "\checkmark"
		estadd local sttrend "\checkmark"
* member FEs + cong FEs + NO controls
eststo: areg z_effort_index ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
		estadd local yrfe "\checkmark"
		estadd local distfe ""
		estadd local membfe "\checkmark"
		estadd local contr ""
		estadd local sttrend ""
* member FEs + cong FEs + controls
eststo: areg z_effort_index ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
		estadd local yrfe "\checkmark"
		estadd local distfe ""
		estadd local membfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend ""
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster z_effort_index ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
		estadd local yrfe "\checkmark"
		estadd local distfe ""
		estadd local membfe "\checkmark"
		estadd local contr "\checkmark"
		estadd local sttrend "\checkmark"
* export table
esttab using "tables/indexeffort_ab.tex", replace nonotes label ///
	title("Australian Ballot \& Index of Legislator Effort" \label{ab-index-effort}) noobs ///
	scalars("yrfe Congress Fixed Effects" "distfe District Fixed Effects" "membfe Member Fixed Effects" ///
			"contr Controls" "sttrend District/Member-Specific Trends" "N Observations") ///
	b(3) se(3) sfmt(%9.3gc) nomtitles nogaps keep(ab) star(* 0.05) varwidth(150) ///
	addnotes("Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable is an" ///
			 "index constructed from the count of private bills sponsored, the roll-call participation rate, and the count" ///
			 "of floor speeches. Control variables include member of majority party, Republican, seniority, past electoral" ///
			 "margin, chair or ranking member of any committee, committee fixed effects, and primary election status in" ///
			 "the state. District- or member-specific trends are district-specific linear trends for specification (3) and" ///
			 "member-specific linear trends for specification (6).")
	

	
*********************************************
*** export tables: legislator effort      ***
*** outcomes: private bill sponsorship,   ***
***           RC participation & speeches ***
*********************************************

*** TABLE 3
*** stacked table: private bill sponsorship, RC participation, speeches ***
*** outcomes: main outcomes
*** treatment: ab
*** sample restrictions: none
file open myfile using "tables/ab_effort.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Legislator Effort \label{ab-effort}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}\\" _n ///
"\hline" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel A. Private Bill Sponsorship}} \\" _n ///
"\input{tables/fragments/frag_priv_ab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel B. Roll-Call Participation Rate}} \\" _n ///
"\input{tables/fragments/frag_rcpart_ab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel C. Floor Speeches}} \\" _n ///
"\input{tables/fragments/frag_speech_ab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \checkmark & & & \\" _n ///
"Member Fixed Effects & & & & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark & & \checkmark & \checkmark \\" _n ///
"District/Member-Specific Trends & & & \checkmark & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `priv_ab_obs' \\" _n ///
"Panel B Observations `rcpart_ab_obs' \\" _n ///
"Panel C Observations `speech_ab_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{7}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable for}\\" _n ///
"\multicolumn{7}{l}{\footnotesize Panel A is the logged count of private bills introduced by the member. The dependent variable for Panel B}\\" _n ///
"\multicolumn{7}{l}{\footnotesize is the roll-call participation rate (measured as a proportion). The dependent variable for Panel C is the logged}\\" _n ///
"\multicolumn{7}{l}{\footnotesize count of floor speeches given by the member. Control variables include member of majority party, Republican,}\\" _n ///
"\multicolumn{7}{l}{\footnotesize seniority, past electoral margin, chair or ranking member of any committee, committee fixed effects, and}\\" _n ///
"\multicolumn{7}{l}{\footnotesize primary election status in the state. District- or member-specific trends are district-specific linear trends}\\" _n ///
"\multicolumn{7}{l}{\footnotesize for specification (3) and member-specific linear trends for specification (6).}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.12
*** stacked table: private bill sponsorship, RC participation, speeches ***
*** outcomes: main outcomes
*** treatment: pcob 
*** sample restrictions: none
file open myfile using "tables/pcob_effort.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Legislator Effort by Ballot Type \label{pcob-effort}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}\\" _n ///
"\hline" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel A. Private Bill Sponsorship}} \\" _n ///
"\input{tables/fragments/frag_priv_pcob.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel B. Roll-Call Participation Rate}} \\" _n ///
"\input{tables/fragments/frag_rcpart_pcob.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel C. Floor Speeches}} \\" _n ///
"\input{tables/fragments/frag_speech_pcob.tex}" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \checkmark & & & \\" _n ///
"Member Fixed Effects & & & & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark & & \checkmark & \checkmark \\" _n ///
"District/Member-Specific Trends & & & \checkmark & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `priv_pcob_obs' \\" _n ///
"Panel B Observations `rcpart_pcob_obs' \\" _n ///
"Panel C Observations `speech_pcob_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{7}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable for}\\" _n ///
"\multicolumn{7}{l}{\footnotesize Panel A is the logged count of private bills introduced by the member. The dependent variable for Panel B}\\" _n ///
"\multicolumn{7}{l}{\footnotesize is the roll-call participation rate (measured as a proportion). The dependent variable for Panel C is the logged}\\" _n ///
"\multicolumn{7}{l}{\footnotesize count of floor speeches given by the member. Control variables include member of majority party, Republican,}\\" _n ///
"\multicolumn{7}{l}{\footnotesize seniority, past electoral margin, chair or ranking member of any committee, committee fixed effects, and}\\" _n ///
"\multicolumn{7}{l}{\footnotesize primary election status in the state. District- or member-specific trends are district-specific linear trends}\\" _n ///
"\multicolumn{7}{l}{\footnotesize for specification (3) and member-specific linear trends for specification (6).}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.16
*** stacked table: private bill sponsorship, RC participation, speeches ***
*** outcomes: main outcomes
*** treatment: lead_ab
*** sample restrictions: none
file open myfile using "tables/leadab_effort.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Legislator Effort \label{leadab-effort}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}\\" _n ///
"\hline" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel A. Private Bill Sponsorship}} \\" _n ///
"\input{tables/fragments/frag_priv_leadab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel B. Roll-Call Participation Rate}} \\" _n ///
"\input{tables/fragments/frag_rcpart_leadab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel C. Floor Speeches}} \\" _n ///
"\input{tables/fragments/frag_speech_leadab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \checkmark & & & \\" _n ///
"Member Fixed Effects & & & & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark & & \checkmark & \checkmark \\" _n ///
"District/Member-Specific Trends & & & \checkmark & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `priv_leadab_obs' \\" _n ///
"Panel B Observations `rcpart_leadab_obs' \\" _n ///
"Panel C Observations `speech_leadab_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{7}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable for}\\" _n ///
"\multicolumn{7}{l}{\footnotesize Panel A is the logged count of private bills introduced by the member. The dependent variable for Panel B}\\" _n ///
"\multicolumn{7}{l}{\footnotesize is the roll-call participation rate (measured as a proportion). The dependent variable for Panel C is the logged}\\" _n ///
"\multicolumn{7}{l}{\footnotesize count of floor speeches given by the member. Control variables include member of majority party, Republican,}\\" _n ///
"\multicolumn{7}{l}{\footnotesize seniority, past electoral margin, chair or ranking member of any committee, committee fixed effects, and}\\" _n ///
"\multicolumn{7}{l}{\footnotesize primary election status in the state. District- or member-specific trends are district-specific linear trends}\\" _n ///
"\multicolumn{7}{l}{\footnotesize for specification (3) and member-specific linear trends for specification (6).}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.19
*** stacked table: private bill sponsorship, RC participation, speeches ***
*** outcomes: main outcomes
*** treatment: ab
*** sample restrictions: excluding states in the south
file open myfile using "tables/nosouth_effort.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Legislator Effort, Excluding the South \label{nosouth-effort}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}\\" _n ///
"\hline" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel A. Private Bill Sponsorship}} \\" _n ///
"\input{tables/fragments/frag_priv_ab_nosouth.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel B. Roll-Call Participation Rate}} \\" _n ///
"\input{tables/fragments/frag_rcpart_ab_nosouth.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel C. Floor Speeches}} \\" _n ///
"\input{tables/fragments/frag_speech_ab_nosouth.tex}" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \checkmark & & & \\" _n ///
"Member Fixed Effects & & & & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark & & \checkmark & \checkmark \\" _n ///
"District/Member-Specific Trends & & & \checkmark & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `priv_ab_nosouth_obs' \\" _n ///
"Panel B Observations `rcpart_ab_nosouth_obs' \\" _n ///
"Panel C Observations `speech_ab_nosouth_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{7}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable for}\\" _n ///
"\multicolumn{7}{l}{\footnotesize Panel A is the logged count of private bills introduced by the member. The dependent variable for Panel B}\\" _n ///
"\multicolumn{7}{l}{\footnotesize is the roll-call participation rate (measured as a proportion). The dependent variable for Panel C is the logged}\\" _n ///
"\multicolumn{7}{l}{\footnotesize count of floor speeches given by the member. Control variables include member of majority party, Republican,}\\" _n ///
"\multicolumn{7}{l}{\footnotesize seniority, past electoral margin, chair or ranking member of any committee, committee fixed effects, and}\\" _n ///
"\multicolumn{7}{l}{\footnotesize primary election status in the state. District- or member-specific trends are district-specific linear trends}\\" _n ///
"\multicolumn{7}{l}{\footnotesize for specification (3) and member-specific linear trends for specification (6). The South is defined as the 11}\\" _n ///
"\multicolumn{7}{l}{\footnotesize states of the former Confederacy.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.14
*** stacked table: private bill sponsorship, RC participation, speeches ***
*** outcomes: main outcomes
*** treatment: ab
*** separately by party
file open myfile using "tables/ab_effort_party.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Legislator Effort by Party\label{ab-effort-party}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}\\" _n ///
"\hline" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel A. Private Bill Sponsorship}} \\" _n ///
"\input{tables/fragments/frag_priv_ab_party.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel B. Roll-Call Participation Rate}} \\" _n ///
"\input{tables/fragments/frag_rcpart_ab_party.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel C. Floor Speeches}} \\" _n ///
"\input{tables/fragments/frag_speech_ab_party.tex}" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \checkmark & & & \\" _n ///
"Member Fixed Effects & & & & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark & & \checkmark & \checkmark \\" _n ///
"District/Member-Specific Trends & & & \checkmark & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `priv_ab_party_obs' \\" _n ///
"Panel B Observations `rcpart_ab_party_obs' \\" _n ///
"Panel C Observations `speech_ab_party_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{7}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable for}\\" _n ///
"\multicolumn{7}{l}{\footnotesize Panel A is the logged count of private bills introduced by the member. The dependent variable for Panel B}\\" _n ///
"\multicolumn{7}{l}{\footnotesize is the roll-call participation rate (measured as a proportion). The dependent variable for Panel C is the logged}\\" _n ///
"\multicolumn{7}{l}{\footnotesize count of floor speeches given by the member. The Republican indicator variable (the constituent term for the}\\" _n ///
"\multicolumn{7}{l}{\footnotesize interaction) is included in all specifications except those with member fixed effects, which fully absorb it.}\\" _n ///
"\multicolumn{7}{l}{\footnotesize Control variables include member of majority party, seniority, past electoral margin, chair or ranking member}\\" _n ///
"\multicolumn{7}{l}{\footnotesize of any committee, committee fixed effects, and primary election status in the state. District- or}\\" _n ///
"\multicolumn{7}{l}{\footnotesize member-specific trends are district-specific linear trends for specification (3) and member-specific linear}\\" _n ///
"\multicolumn{7}{l}{\footnotesize trends for specification (6).}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile

*** TABLE A.8
*** stacked table: private bill sponsorship & speeches ***
*** outcomes: count measures
*** treatment: ab
*** sample restrictions: none
*** specification: poisson regression
file open myfile using "tables/pois_effort.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{Poisson Results: \\ Legislator Effort \label{pois-effort}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}\\" _n ///
"\hline" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel A. Private Bill Sponsorship}} \\" _n ///
"\input{tables/fragments/frag_priv_pois.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel B. Floor Speeches}} \\" _n ///
"\input{tables/fragments/frag_speech_pois.tex}" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \checkmark & & & \\" _n ///
"Member Fixed Effects & & & & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark & & \checkmark & \checkmark \\" _n ///
"District/Member-Specific Trends & & & \checkmark & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `priv_pois_obs' \\" _n ///
"Panel B Observations `speech_pois_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{7}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. Reported coefficients are}\\" _n ///
"\multicolumn{7}{l}{\footnotesize estimated from Poisson models. The dependent variable for Panel A is the count of private bills}\\" _n ///
"\multicolumn{7}{l}{\footnotesize introduced by the member. The dependent variable for Panel B is the count of floor speeches given by}\\" _n ///
"\multicolumn{7}{l}{\footnotesize the member. Control variables include member of majority party, Republican, seniority, past electoral}\\" _n ///
"\multicolumn{7}{l}{\footnotesize margin, chair or ranking member of any committee, committee fixed effects, and primary election status}\\" _n ///
"\multicolumn{7}{l}{\footnotesize in the state. District- or member-specific trends are district-specific linear trends for specification}\\" _n ///
"\multicolumn{7}{l}{\footnotesize (3) and member-specific linear trends for specification (6). The South is defined as the 11 states of}\\" _n ///
"\multicolumn{7}{l}{\footnotesize the former Confederacy.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile


*****************************
*** plots of (pre-)trends ***
*****************************

* create treatment/control states based on year of adoption
bys state_abbrev ab: egen temp_min_yr_ab = min(year) if ab==1
bys state_abbrev: egen min_yr_ab = min(temp_min_yr_ab)
drop temp_min_yr_ab

gen group_min_yr_ab = "1888-1890" if min_yr_ab<=1890
replace group_min_yr_ab = "1891-1893" if min_yr_ab>=1891 & min_yr_ab<=1893
replace group_min_yr_ab = "1894-1896" if min_yr_ab>=1894 & min_yr_ab<=1896
replace group_min_yr_ab = "post-1896" if min_yr_ab>1896

local cond if flag_mult_mc!=1 & dist<98 & _merge_fino==3
set scheme s1color

* FIGURE A.2 (d)
* trends for log sponsorship of all private bills
binscatter log_private year `cond' & year<=1908, ///
	msymbols(O T S D) col(navy maroon dkgreen dkorange) plotregion(lw(0)) ///
	by(group_min_yr_ab) discrete line(connect) legend(off) ///
	text(3.71 1904 "1888-1890", place(e) col(navy) size(med)) ///
	text(3.68 1900 "1891-1893", place(c) col(maroon) size(med)) ///
	text(3.10 1900 "1894-1896", place(c) col(dkgreen) size(med)) ///
	text(2.86 1902 "Post-1896", place(e) col(dkorange) size(med)) ///
	xlabel(1880(4)1908,labsize(med)) xtitle("Election Year", size(med)) ///
	ytitle("ln(Count Private Bills + 1)", size(med)) ///
	ylabel(2(.25)4,angle(horizontal) labsize(med)) xsize(8) ysize(6)
graph export "figs/pretrends_priv.pdf", replace

* FIGURE A.2 (e)
* trends for roll-call participation rate
binscatter rc_part_rate year `cond' & year<=1908, ///
	msymbols(O T S D) col(navy maroon dkgreen dkorange) plotregion(lw(0)) ///
	by(group_min_yr_ab) discrete line(connect) legend(off) ///
	text(.79 1907.8 "1888-1890", place(w) col(navy) size(med)) ///
	text(.70 1887.5 "1891-1893", place(c) col(maroon) size(med)) ///
	text(.57 1907 "1894-1896", place(c) col(dkgreen) size(med)) ///
	text(.75 1897 "Post-1896", place(c) col(dkorange) size(med)) ///
	xlabel(1880(4)1908,labsize(med)) xtitle("Election Year", size(med)) ///
	ytitle("Roll-Call Participation Rate", size(med)) ///
	ylabel(.4(.1).9,angle(horizontal) labsize(med)) xsize(8) ysize(6)
graph export "figs/pretrends_rcpart.pdf", replace

* FIGURE A.2 (f)
* trends for floor speeches
binscatter log_speeches year `cond' & year<=1908, ///
	msymbols(O T S D) col(navy maroon dkgreen dkorange) plotregion(lw(0)) ///
	by(group_min_yr_ab) discrete line(connect) legend(off) ///
	text(2.38 1903 "1888-1890", place(c) col(navy) size(med)) ///
	text(2.6 1886 "1891-1893", place(c) col(maroon) size(med)) ///
	text(1.55 1898 "1894-1896", place(c) col(dkgreen) size(med)) ///
	text(1.8 1892 "Post-1896", place(c) col(dkorange) size(med)) ///
	xlabel(1880(4)1908,labsize(med)) xtitle("Election Year", size(med)) ///
	ytitle("ln(Count Speeches + 1)", size(med)) ///
	ylabel(1(.5)3,angle(horizontal) labsize(med)) xsize(8) ysize(6)
graph export "figs/pretrends_speech.pdf", replace

* FIGURE 1
* toy example of trends as to why to use a diff-in-diff
binscatter private year if flag_mult_mc!=1 & dist<98 & _merge_fino==3 & ///
	(min_yr_ab==1890 | min_yr_ab>1896) & year>=1886 & year<=1902, ///
	by(group_min_yr_ab) line(connect) discrete legend(off) ///
	xline(1890, lc(black) lp(shortdash)) msymbols(O T) col(navy maroon) ///
	ytitle("Ave. Private Bills Sponsored per Member", size(med)) ///
	xlabel(1886(4)1902,labsize(med)) xtitle("Election Year", size(med)) ///
	ylabel(15(5)45,angle(horizontal) labsize(med)) xsize(8) ysize(6) ///
	text(27 1893.2 "Implemented AB in 1890", place(c) col(navy) size(med)) ///
	text(17 1894 "Implemented AB after 1904", place(c) col(maroon) size(med))
graph export "figs/example_DiD.pdf", replace


**********************************************
*** histograms of log-transformed outcomes ***
**********************************************
* FIGURE A.1 (g)
* count private bills sponsored
hist private `cond', fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_priv.pdf", replace
* FIGURE A.1 (h)
* log private bills + 1
hist log_private `cond', fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_logpriv.pdf", replace

* FIGURE A.1 (i)
* count floor speeches
hist n_speech200words `cond', fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_speech.pdf", replace
* FIGURE A.1 (j)
* log floor speeches + 1
hist log_speeches `cond', fcol(navy) lcol(black) xsize(8) ysize(6) ///
	xlabel(,labsize(large)) xtitle(,size(large)) ytitle(,size(large)) ///
	ylabel(,angle(horizontal) labsize(large))
graph export "figs/hist_logspeech.pdf", replace


****************************
*** party unity analysis ***
****************************
set more 1
local controls primary margin chr_any hsemaj_r republican hse_terms ///
	com_pens com_pinv com_clms com_maff com_naff com_cmrc com_iaff com_bild ///
	com_land com_judi com_rhar com_agri com_bank com_educ com_faff ///
	com_imig com_labo com_ways
local cond if flag_mult_mc!=1 & dist<98 & _merge_fino==3

** TABLE A.23, PANEL A
** create a table fragment for a combined/stacked table
** outcome: party unity score
** treatment: ab
eststo clear
local partyunity_ab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg party_unity_score ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_obs = "`partyunity_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg party_unity_score ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_obs = "`partyunity_ab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_obs = "`partyunity_ab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg party_unity_score ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_obs = "`partyunity_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg party_unity_score ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_obs = "`partyunity_ab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_obs = "`partyunity_ab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_partyunity_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines
	
** TABLE A.23, PANEL B
** create a table fragment for a combined/stacked table
** outcome: party unity score
** treatment: pcob
eststo clear
local partyunity_pcob_obs ""
* district FEs + cong FEs + NO controls
eststo: areg party_unity_score pc_sw ob_sw i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_pcob_obs = "`partyunity_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg party_unity_score pc_sw ob_sw i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_pcob_obs = "`partyunity_pcob_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score pc_sw ob_sw cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_pcob_obs = "`partyunity_pcob_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg party_unity_score pc_sw ob_sw i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_pcob_obs = "`partyunity_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg party_unity_score pc_sw ob_sw i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_pcob_obs = "`partyunity_pcob_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score pc_sw ob_sw cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_pcob_obs = "`partyunity_pcob_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_partyunity_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(pc_sw ob_sw) star(* 0.05) nolines
	
** TABLE A.23, PANEL C
** create a table fragment for a combined/stacked table
** outcome: party unity score
** treatment: lead_ab
eststo clear
local partyunity_leadab_obs ""
* district FEs + cong FEs + NO controls
eststo: areg party_unity_score lead_ab i.congress `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_leadab_obs = "`partyunity_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg party_unity_score lead_ab i.congress `controls' `cond', absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_leadab_obs = "`partyunity_leadab_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score lead_ab cong_* `controls' `cond', i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_leadab_obs = "`partyunity_leadab_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg party_unity_score lead_ab i.congress `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_leadab_obs = "`partyunity_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg party_unity_score lead_ab i.congress `controls' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_leadab_obs = "`partyunity_leadab_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score lead_ab cong_* `controls' `cond', i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_leadab_obs = "`partyunity_leadab_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_partyunity_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(lead_ab) star(* 0.05) nolines
	
** TABLE A.23, PANEL D	
** create a table fragment for a combined/stacked table
** outcome: party unity score
** treatment: ab
** sample restrictions: excluding states in the south
eststo clear
local partyunity_ab_nosouth_obs ""
* district FEs + cong FEs + NO controls
eststo: areg party_unity_score ab i.congress `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_nosouth_obs = "`partyunity_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls
eststo: areg party_unity_score ab i.congress `controls' `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_nosouth_obs = "`partyunity_ab_nosouth_obs' & `temp_N'"
* district FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score ab cong_* `controls' `cond' & south==0, i(_dist_id) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_nosouth_obs = "`partyunity_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + NO controls
eststo: areg party_unity_score ab i.congress `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_nosouth_obs = "`partyunity_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls
eststo: areg party_unity_score ab i.congress `controls' `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_nosouth_obs = "`partyunity_ab_nosouth_obs' & `temp_N'"
* member FEs + cong FEs + controls + district-specific linear trends
eststo: fetrend_cluster party_unity_score ab cong_* `controls' `cond' & south==0, i(icpsrno) t(congress) c(state_icpsr) o(1)
	local temp_N : di %9.0fc e(N)
	local partyunity_ab_nosouth_obs = "`partyunity_ab_nosouth_obs' & `temp_N'"
* fragment of table
esttab using "tables/fragments/frag_partyunity_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(ab) star(* 0.05) nolines

	
*****************************************
*** export stacked table: party unity ***
*** outcomes:  party unity            ***
*****************************************

*** TABLE A.23
*** stacked table: party unity ***
*** all specifications stacked
*** treatment: ab
*** sample restrictions: none
file open myfile using "tables/partyunity.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Party Unity \label{partyunity}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}\\" _n ///
"\hline" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel A. Main Specification}} \\" _n ///
"\input{tables/fragments/frag_partyunity_ab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel B. Decomposing by Ballot Type}} \\" _n ///
"\input{tables/fragments/frag_partyunity_pcob.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel C. Anticipatory Legislator Behavior}} \\" _n ///
"\input{tables/fragments/frag_partyunity_leadab.tex}" _n ///
"\multicolumn{7}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{7}{l}{\textit{Panel D. Excluding States in the South}} \\" _n ///
"\input{tables/fragments/frag_partyunity_ab_nosouth.tex}" _n ///
"\multicolumn{7}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Congress Fixed Effects & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\" _n ///
"District Fixed Effects & \checkmark & \checkmark & \checkmark & & & \\" _n ///
"Member Fixed Effects & & & & \checkmark & \checkmark & \checkmark \\" _n ///
"Controls & & \checkmark & \checkmark & & \checkmark & \checkmark \\" _n ///
"District/Member-Specific Trends & & & \checkmark & & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `partyunity_ab_obs' \\" _n ///
"Panel B Observations `partyunity_pcob_obs' \\" _n ///
"Panel C Observations `partyunity_leadab_obs' \\" _n ///
"Panel D Observations `partyunity_ab_nosouth_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{7}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable for}\\" _n ///
"\multicolumn{7}{l}{\footnotesize all panels is the party unity score. Control variables include member of majority party, Republican,}\\" _n ///
"\multicolumn{7}{l}{\footnotesize seniority, past electoral margin, chair or ranking member of any committee, committee fixed effects,}\\" _n ///
"\multicolumn{7}{l}{\footnotesize and primary election status in the state. District- or member-specific trends are district-specific}\\" _n ///
"\multicolumn{7}{l}{\footnotesize  linear trends for specification (3) and member-specific linear trends for specification (6).}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile



*******************************
*** responsiveness analysis ***
*******************************
gen _vote_r_pres = 1 - _vote_d_pres
gen ab_vote_r_pres =  ab * _vote_r_pres
gen pc_sw_r_pres = pc_sw * _vote_r_pres
gen ob_sw_r_pres = ob_sw * _vote_r_pres
gen lead_ab_r_pres = lead_ab * _vote_r_pres
label var _vote_r_pres "GOP Pres. Share"
label var ab_vote_r_pres "Australian Ballot $\times$ GOP Pres. Share"
label var pc_sw_r_pres "Party Column $\times$ GOP Pres. Share"
label var ob_sw_r_pres "Office Bloc $\times$ GOP Pres. Share"
label var lead_ab_r_pres "Australian Ballot\textsubscript{ $ t+1 $ } $\times$ GOP Pres. Share"

set more 1
local cond if flag_mult_mc!=1 & dist<98 & _merge_fino==3
local controls primary margin chr_any hsemaj_r republican hse_terms ///
	com_pens com_pinv com_clms com_maff com_naff com_cmrc com_iaff com_bild ///
	com_land com_judi com_rhar com_agri com_bank com_educ com_faff ///
	com_imig com_labo com_ways


** TABLE A.22, PANEL A
** create a table fragment for a combined/stacked table
** outcome: nokken-poole score
** treatment: ab
eststo clear
local respons_ab_obs ""
local indvar "ab_vote_r_pres ab _vote_r_pres"

* district FEs + NO congress FEs 
eststo: areg nokken_poole_dim1 `indvar' `cond', absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_ab_obs = "`respons_ab_obs' & `temp_N'"
	
* district FEs + congress FEs + controls
eststo: areg nokken_poole_dim1 `indvar' i.congress `cond', absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_ab_obs = "`respons_ab_obs' & `temp_N'"

* member FEs + NO congress FEs
eststo: areg nokken_poole_dim1 `indvar' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_ab_obs = "`respons_ab_obs' & `temp_N'"
	
* member FEs + congress FEs 
eststo: areg nokken_poole_dim1 `indvar' i.congress  `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_ab_obs = "`respons_ab_obs' & `temp_N'"

* fragment of table
esttab using "tables/fragments/frag_respons_ab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(`indvar') star(* 0.05) nolines

** TABLE A.22, PANEL B
** create a table fragment for a combined/stacked table
** outcome: nokken-poole score
** treatment: pcob
eststo clear
local respons_pcob_obs ""
local indvar "pc_sw_r_pres ob_sw_r_pres pc_sw ob_sw _vote_r_pres"

* district FEs + NO congress FEs 
eststo: areg nokken_poole_dim1 `indvar' `cond', absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_pcob_obs = "`respons_pcob_obs' & `temp_N'"
	
* district FEs + congress FEs + controls
eststo: areg nokken_poole_dim1 `indvar' i.congress `cond', absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_pcob_obs = "`respons_pcob_obs' & `temp_N'"

* member FEs + NO congress FEs
eststo: areg nokken_poole_dim1 `indvar' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_pcob_obs = "`respons_pcob_obs' & `temp_N'"
	
* member FEs + congress FEs 
eststo: areg nokken_poole_dim1 `indvar' i.congress  `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_pcob_obs = "`respons_pcob_obs' & `temp_N'"

* fragment of table
esttab using "tables/fragments/frag_respons_pcob.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(`indvar') star(* 0.05) nolines	

** TABLE A.22, PANEL C
** create a table fragment for a combined/stacked table
** outcome: nokken-poole score
** treatment: lead_ab
eststo clear
local respons_leadab_obs ""
local indvar "lead_ab_r_pres lead_ab _vote_r_pres"

* district FEs + NO congress FEs 
eststo: areg nokken_poole_dim1 `indvar' `cond', absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_leadab_obs = "`respons_leadab_obs' & `temp_N'"
	
* district FEs + congress FEs + controls
eststo: areg nokken_poole_dim1 `indvar' i.congress `cond', absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_leadab_obs = "`respons_leadab_obs' & `temp_N'"

* member FEs + NO congress FEs
eststo: areg nokken_poole_dim1 `indvar' `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_leadab_obs = "`respons_leadab_obs' & `temp_N'"
	
* member FEs + congress FEs 
eststo: areg nokken_poole_dim1 `indvar' i.congress  `cond', absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_leadab_obs = "`respons_leadab_obs' & `temp_N'"

* fragment of table
esttab using "tables/fragments/frag_respons_leadab.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(`indvar') star(* 0.05) nolines	
	
** TABLE A.22, PANEL D
** create a table fragment for a combined/stacked table
** outcome: nokken-poole score
** treatment: lead_ab
** sample restrictions: excluding states in the south
eststo clear
local respons_ab_nosouth_obs ""
local indvar "ab_vote_r_pres ab _vote_r_pres"

* district FEs + NO congress FEs 
eststo: areg nokken_poole_dim1 `indvar' `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_ab_nosouth_obs = "`respons_ab_nosouth_obs' & `temp_N'"
	
* district FEs + congress FEs + controls
eststo: areg nokken_poole_dim1 `indvar' i.congress `cond' & south==0, absorb(_dist_id) cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local respons_ab_nosouth_obs = "`respons_ab_nosouth_obs' & `temp_N'"

* member FEs + NO congress FEs
eststo: areg nokken_poole_dim1 `indvar' `cond'& south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_ab_nosouth_obs = "`respons_ab_nosouth_obs' & `temp_N'"
	
* member FEs + congress FEs 
eststo: areg nokken_poole_dim1 `indvar' i.congress  `cond' & south==0, absorb(icpsrno) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local respons_ab_nosouth_obs = "`respons_ab_nosouth_obs' & `temp_N'"

* fragment of table
esttab using "tables/fragments/frag_respons_ab_nosouth.tex", replace nonotes label ///
	noobs fragment b(3) se(3) sfmt(%9.3gc) nomtitles nonumbers nogaps keep(`indvar') star(* 0.05) nolines
	

********************************************
*** export stacked table: responsiveness ***
*** outcomes:  responsiveness            ***
********************************************

*** TABLE A.22
*** stacked table: responsiveness ***
*** all specifications stacked
file open myfile using "tables/responsiveness.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Responsiveness \label{responsiveness}}" _n ///
"\begin{tabular}{l*{6}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)}\\" _n ///
"\hline" _n ///
"\multicolumn{5}{l}{} \\[-2ex]" _n ///
"\multicolumn{5}{l}{\textit{Panel A. Main Specification}} \\" _n ///
"\input{tables/fragments/frag_respons_ab.tex}" _n ///
"\multicolumn{5}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{5}{l}{\textit{Panel B. Decomposing by Ballot Type}} \\" _n ///
"\input{tables/fragments/frag_respons_pcob.tex}" _n ///
"\multicolumn{5}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{5}{l}{\textit{Panel C. Anticipatory Legislator Behavior}} \\" _n ///
"\input{tables/fragments/frag_respons_leadab.tex}" _n ///
"\multicolumn{5}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{5}{l}{\textit{Panel D. Excluding States in the South}} \\" _n ///
"\input{tables/fragments/frag_respons_ab_nosouth.tex}" _n ///
"\multicolumn{5}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"District Fixed Effects & \checkmark & \checkmark & & \\" _n ///
"Member Fixed Effects & & & \checkmark & \checkmark \\" _n ///
"Congress Fixed Effects & & \checkmark & & \checkmark \\" _n ///
"\hline" _n ///
"Panel A Observations `respons_ab_obs' \\" _n ///
"Panel B Observations `respons_pcob_obs' \\" _n ///
"Panel C Observations `respons_leadab_obs' \\" _n ///
"Panel D Observations `respons_ab_nosouth_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{5}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05.}\\" _n ///
"\multicolumn{5}{l}{\footnotesize The dependent variable for all panels is the first dimension of Nokken-Poole scores.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile
			 


			 
**************************************
*** discretion in roll-call voting ***
**************************************
preserve

keep if flag_mult_mc!=1 & _merge_fino==3 & inlist(party_code,100,200) & congress>=47 & congress<=63

* calculate the mean absolute distance and mean squared distance
gen abs_dist = abs(nominate_dim1 - ave_sen_nom1)
gen sq_dist = (nominate_dim1 - ave_sen_nom1)^2

bys congress state_abbrev party_code: egen ave_abs_dist = mean(abs_dist)
bys congress state_abbrev party_code: egen ave_sq_dist = mean(sq_dist)
bys congress state_abbrev party_code: egen sd_nom1 = sd(nominate_dim1 )
bys congress state_abbrev party_code: keep if _n==1

* state x party FEs and congress x party FEs
egen st_party = group(state_abbrev party_code)
egen congbyparty = group(congress party_code)
quietly tab congbyparty, gen(_congbyparty_)

*** TABLE 4, TABLE A.13, TABLE A.17
*** analysis: did the australian ballot allow representatives in the house more
*** discretion in their roll-call voting from their state party leaders
foreach treatvar in "ab" "pc_sw ob_sw" "lead_ab" {
	if "`treatvar'"=="ab" {
		local filename ab_discretion
		local tablelab ab-discretion
	}
	if "`treatvar'"=="pc_sw ob_sw" {
		local filename pcob_discretion
		local tablelab pcob-discretion
	}
	if "`treatvar'"=="lead_ab" {
		local filename leadab_discretion
		local tablelab leadab-discretion
	}
	eststo clear
	local depvar ave_sq_dist 
		* state FEs + congress FEs
		eststo: areg `depvar' `treatvar' i.congress, absorb(state_icpsr) cluster(state_icpsr)
			estadd local stfe "\checkmark"
			estadd local stpartyfe ""
			estadd local congfe "\checkmark" 
			estadd local congpartyfe ""
			estadd local sttrend ""
		
		* state FEs + congress FEs + state-specific trends
		*eststo: areg `depvar' `treatvar' i.congress i.state_icpsr#c.congress, absorb(state_icpsr) cluster(state_icpsr)
		eststo: fetrend_cluster `depvar' `treatvar' cong_*, i(state_icpsr) t(congress) c(state_icpsr) o(1)
			estadd local stfe "\checkmark"
			estadd local stpartyfe ""
			estadd local congfe "\checkmark" 
			estadd local congpartyfe ""
			estadd local sttrend "\checkmark"

		* state-party FEs + congress-party FEs
		eststo: areg `depvar' `treatvar' i.congbyparty, absorb(st_party) cluster(state_icpsr)
			estadd local stfe ""
			estadd local stpartyfe "\checkmark"
			estadd local congfe "" 
			estadd local congpartyfe "\checkmark"
			estadd local sttrend ""
		
		* state-party FEs + congress-party FEs + state-party trends
		*eststo: areg `depvar' `treatvar' i.congbyparty i.st_party#c.congress, absorb(st_party) cluster(state_icpsr)
		eststo: fetrend_cluster `depvar' `treatvar' _congbyparty_*, i(st_party) t(congress) c(state_icpsr) o(1)
			estadd local stfe ""
			estadd local stpartyfe "\checkmark"
			estadd local congfe "" 
			estadd local congpartyfe "\checkmark"
			estadd local sttrend "\checkmark"


	esttab using "tables/`filename'.tex", replace nonotes label ///
		title("Discretion from the State Party on Roll-Call Voting" \label{`tablelab'}) noobs nomtitles ///
		scalars("stfe State FEs" "congfe Congress FEs" ///
				"stpartyfe State-Party FEs" "congpartyfe Congress-Party FEs" ///
				"congfe Congress FEs" "sttrend Unit-Specific Trends" "N Observations") ///
		b(3) se(3) sfmt(%9.3gc) nogaps star(* 0.05) varwidth(150) keep(`treatvar') ///
		addnotes("Robust standard errors clustered by state are in parentheses. * p $<$ 0.05." ///
				 "Dependent variable is the mean squared distance from a House" ///
				 "state-party delegation to the corresponding Senate delegation." ///
				 "Unit-specific trends are state-specific linear trends for model (2) and" ///
				 "state-party-specific linear trends for model (4).")
}

*** TABLE A.6
*** alternative outcome -- discretion
local treatvar "ab" 
eststo clear
local depvar ave_abs_dist
		* state FEs + congress FEs
		eststo: areg `depvar' `treatvar' i.congress, absorb(state_icpsr) cluster(state_icpsr)
			estadd local stfe "\checkmark"
			estadd local stpartyfe ""
			estadd local congfe "\checkmark" 
			estadd local congpartyfe ""
			estadd local sttrend ""
		
		* state FEs + congress FEs + state-specific trends
		*eststo: areg `depvar' `treatvar' i.congress i.state_icpsr#c.congress, absorb(state_icpsr) cluster(state_icpsr)
		eststo: fetrend_cluster `depvar' `treatvar' cong_*, i(state_icpsr) t(congress) c(state_icpsr) o(1)
			estadd local stfe "\checkmark"
			estadd local stpartyfe ""
			estadd local congfe "\checkmark" 
			estadd local congpartyfe ""
			estadd local sttrend "\checkmark"

		* state-party FEs + congress-party FEs
		eststo: areg `depvar' `treatvar' i.congbyparty, absorb(st_party) cluster(state_icpsr)
			estadd local stfe ""
			estadd local stpartyfe "\checkmark"
			estadd local congfe "" 
			estadd local congpartyfe "\checkmark"
			estadd local sttrend ""
		
		* state-party FEs + congress-party FEs + state-party trends
		*eststo: areg `depvar' `treatvar' i.congbyparty i.st_party#c.congress, absorb(st_party) cluster(state_icpsr)
		eststo: fetrend_cluster `depvar' `treatvar' _congbyparty_*, i(st_party) t(congress) c(state_icpsr) o(1)
			estadd local stfe ""
			estadd local stpartyfe "\checkmark"
			estadd local congfe "" 
			estadd local congpartyfe "\checkmark"
			estadd local sttrend "\checkmark"

	esttab using "tables/altoutcome_discretion.tex", replace nonotes label ///
		title("Discretion from the State Party on Roll-Call Voting, \\ Alternative Outcome Measure" \label{altoutcome-discretion}) noobs nomtitles ///
		scalars("stfe State FEs" "congfe Congress FEs" ///
				"stpartyfe State-Party FEs" "congpartyfe Congress-Party FEs" ///
				"congfe Congress FEs" "sttrend Unit-Specific Trends" "N Observations") ///
		b(3) se(3) sfmt(%9.3gc) nogaps star(* 0.05) varwidth(150) keep(`treatvar') ///
		addnotes("Robust standard errors clustered by state are in parentheses. * p $<$ 0.05." ///
				 "Dependent variable is the mean absolute distance from a House" ///
				 "state-party delegation to the corresponding Senate delegation." ///
				 "Unit-specific trends are state-specific linear trends for model (2) and" ///
				 "state-party-specific linear trends for model (4).")

*** TABLE A.20
*** excluding the south
keep if south==0
eststo clear
local treatvar ab
local depvar ave_sq_dist

	* state FEs + congress FEs
	eststo: areg `depvar' `treatvar' i.congress, absorb(state_icpsr) cluster(state_icpsr)
		estadd local stfe "\checkmark"
		estadd local stpartyfe ""
		estadd local congfe "\checkmark" 
		estadd local congpartyfe ""
		estadd local sttrend ""
	
	* state FEs + congress FEs + state-specific trends
	*eststo: areg `depvar' `treatvar' cong_* i.state_icpsr#c.congress, absorb(state_icpsr) cluster(state_icpsr)
	eststo: fetrend_cluster `depvar' `treatvar' cong_* , i(state_icpsr) t(congress) c(state_icpsr) o(1)
		estadd local stfe "\checkmark"
		estadd local stpartyfe ""
		estadd local congfe "\checkmark" 
		estadd local congpartyfe ""
		estadd local sttrend "\checkmark"

	* state-party FEs + congress-party FEs
	eststo: areg `depvar' `treatvar' i.congbyparty , absorb(st_party) cluster(state_icpsr)
		estadd local stfe ""
		estadd local stpartyfe "\checkmark"
		estadd local congfe "" 
		estadd local congpartyfe "\checkmark"
		estadd local sttrend ""
	
	* state-party FEs + congress-party FEs + state-party trends
	*eststo: areg `depvar' `treatvar' i.congbyparty i.st_party#c.congress, absorb(st_party) cluster(state_icpsr)
	eststo: fetrend_cluster `depvar' `treatvar' _congbyparty_* , i(state_icpsr) t(congress) c(state_icpsr) o(1)
		estadd local stfe ""
		estadd local stpartyfe "\checkmark"
		estadd local congfe "" 
		estadd local congpartyfe "\checkmark"
		estadd local sttrend "\checkmark"

	esttab using "tables/nosouth_discretion.tex", replace nonotes label ///
		title("Discretion from the State Party on Roll-Call Voting, \\ Excluding the South" \label{nosouth-discretion}) noobs nomtitles ///
		scalars("stfe State FEs" "congfe Congress FEs" ///
				"stpartyfe State-Party FEs" "congpartyfe Congress-Party FEs" ///
				"congfe Congress FEs" "sttrend Unit-Specific Trends" "N Observations") ///
		b(3) se(3) sfmt(%9.3gc) nogaps star(* 0.05) varwidth(150) keep(`treatvar') ///
		addnotes("Robust standard errors clustered by state are in parentheses. * p $<$ 0.05." ///
				 "Dependent variable is the mean squared distance from a House" ///
				 "state-party delegation to the corresponding Senate delegation." ///
				 "Unit-specific trends are state-specific linear trends for model (2) and" ///
				 "state-party-specific linear trends for model (4). The South is" ///
				 "defined as the 11 states of the former Confederacy.")

restore


************************************
*** staggered DiD specifications ***
************************************
preserve

bys _dist_id ab: egen temp_min_cong_ab = min(congress) if ab==1
bys _dist_id: egen min_cong_ab = min(temp_min_cong_ab)
drop temp_min_cong_ab
* create treatment variable for csdid command
gen _gvar = min_cong_ab
replace _gvar = 0 if missing(_gvar) & !missing(ab)
drop if missing(log_private) & !inlist(year,1874,1876,1878,1882)
* create treatment variable for did_imputation command
gen _Ei = _gvar
replace _Ei = . if _gvar==0
drop if flag_mult_mc==1 | dist>=98 | missing(_dist_id)
* state-icpsr identifiers to deal with SEs for C-SA (2021)
* there is one legislator who represented two states but the panel
* identifier must be nested within the cluster for C-SA (2021)
egen st_icpsrno = group(state_icpsr icpsrno)

*** TABLE A.10, PANEL A
*** private bills ***
set seed 1234
local priv_did_est ""
local priv_did_se ""
local priv_did_obs ""

foreach var of varlist _dist_id st_icpsrno {
* TWFE
areg log_private ab i.congress, absorb(`var') cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local priv_did_est = "`priv_did_est' & `temp_est'"
	local priv_did_se = "`priv_did_se' & (`temp_se')"
	local priv_did_obs = "`priv_did_obs' & `temp_N'"
* de Chaisemartin and D'Haultfoeuille (2020), AER
did_multiplegt  log_private `var' congress ab, breps(250) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N_effect_0)
	local temp_est = e(effect_0)
	local temp_se = e(se_effect_0)
	local temp_t = abs(`temp_est' / `temp_se')
	local temp_est : di %9.3fc e(effect_0)
	local temp_se : di %9.3fc e(se_effect_0)
	local temp_se = strtrim("`temp_se'")
		if `temp_t' > 1.96 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local priv_did_est = "`priv_did_est' & `temp_est'"
	local priv_did_se = "`priv_did_se' & (`temp_se')"
	local priv_did_obs = "`priv_did_obs' & `temp_N'"
* Callaway and Sant'Anna (2021)
csdid log_private, ivar(`var') time(congress) gvar(_gvar) agg(simple) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local priv_did_est = "`priv_did_est' & `temp_est'"
	local priv_did_se = "`priv_did_se' & (`temp_se')"
	local priv_did_obs = "`priv_did_obs' & `temp_N'"
*  Borusyak, Jaravel, and Spiess (2022)
did_imputation log_private `var' congress _Ei, autosample cluster(state_icpsr) maxit(500)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}	
	local priv_did_est = "`priv_did_est' & `temp_est'"
	local priv_did_se = "`priv_did_se' & (`temp_se')"
	local priv_did_obs = "`priv_did_obs' & `temp_N'"
}
file open myfile using "tables/fragments/frag_priv_did.tex", write replace
file write myfile ///
"Treatment Effect `priv_did_est' \\" _n ///
"`priv_did_se' \\" _n
file close myfile

*** TABLE A.10, PANEL B
*** roll-call participation ***
set seed 1234
local rcpart_did_est ""
local rcpart_did_se ""
local rcpart_did_obs ""

foreach var of varlist _dist_id st_icpsrno {
* TWFE
areg rc_part_rate ab i.congress, absorb(`var') cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local rcpart_did_est = "`rcpart_did_est' & `temp_est'"
	local rcpart_did_se = "`rcpart_did_se' & (`temp_se')"
	local rcpart_did_obs = "`rcpart_did_obs' & `temp_N'"
* de Chaisemartin and D'Haultfoeuille (2020), AER
did_multiplegt rc_part_rate `var' congress ab, breps(250) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N_effect_0)
	local temp_est = e(effect_0)
	local temp_se = e(se_effect_0)
	local temp_t = abs(`temp_est' / `temp_se')
	local temp_est : di %9.3fc e(effect_0)
	local temp_se : di %9.3fc e(se_effect_0)
	local temp_se = strtrim("`temp_se'")
		if `temp_t' > 1.96 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local rcpart_did_est = "`rcpart_did_est' & `temp_est'"
	local rcpart_did_se = "`rcpart_did_se' & (`temp_se')"
	local rcpart_did_obs = "`rcpart_did_obs' & `temp_N'"
* Callaway and Sant'Anna (2021)
csdid rc_part_rate, ivar(`var') time(congress) gvar(_gvar) agg(simple) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local rcpart_did_est = "`rcpart_did_est' & `temp_est'"
	local rcpart_did_se  = "`rcpart_did_se' & (`temp_se')"
	local rcpart_did_obs = "`rcpart_did_obs' & `temp_N'"
*  Borusyak, Jaravel, and Spiess (2022)
did_imputation rc_part_rate `var' congress _Ei, autosample cluster(state_icpsr) maxit(500)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}	
	local rcpart_did_est = "`rcpart_did_est' & `temp_est'"
	local rcpart_did_se = "`rcpart_did_se' & (`temp_se')"
	local rcpart_did_obs = "`rcpart_did_obs' & `temp_N'"
}
file open myfile using "tables/fragments/frag_rcpart_did.tex", write replace
file write myfile ///
"Treatment Effect `rcpart_did_est' \\" _n ///
"`rcpart_did_se' \\" _n
file close myfile

** TABLE A.22, PANEL C
*** speeches ***
set seed 1234
local speech_did_est ""
local speech_did_se ""
local speech_did_obs ""

foreach var of varlist _dist_id st_icpsrno {
* TWFE
areg log_speeches ab i.congress, absorb(`var') cluster(state_icpsr)	
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local speech_did_est = "`speech_did_est' & `temp_est'"
	local speech_did_se = "`speech_did_se' & (`temp_se')"
	local speech_did_obs = "`speech_did_obs' & `temp_N'"
* de Chaisemartin and D'Haultfoeuille (2020), AER
did_multiplegt log_speeches `var' congress ab, breps(250) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N_effect_0)
	local temp_est = e(effect_0)
	local temp_se = e(se_effect_0)
	local temp_t = abs(`temp_est' / `temp_se')
	local temp_est : di %9.3fc e(effect_0)
	local temp_se : di %9.3fc e(se_effect_0)
	local temp_se = strtrim("`temp_se'")
		if `temp_t' > 1.96 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local speech_did_est = "`speech_did_est' & `temp_est'"
	local speech_did_se = "`speech_did_se' & (`temp_se')"
	local speech_did_obs = "`speech_did_obs' & `temp_N'"
* Callaway and Sant'Anna (2021)
csdid log_speeches, ivar(`var') time(congress) gvar(_gvar) agg(simple) cluster(state_icpsr)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}
	local speech_did_est = "`speech_did_est' & `temp_est'"
	local speech_did_se  = "`speech_did_se' & (`temp_se')"
	local speech_did_obs = "`speech_did_obs' & `temp_N'"
*  Borusyak, Jaravel, and Spiess (2022)
did_imputation log_speeches `var' congress _Ei, autosample cluster(state_icpsr) maxit(500)
	local temp_N : di %9.0fc e(N)
	local temp_est : di %9.3fc r(table)[1,1]
	local temp_se : di %9.3fc r(table)[2,1]
	local temp_se = strtrim("`temp_se'")
	local temp_p : di %9.3fc r(table)[4,1]
		if `temp_p' < .05 {
			local temp_est = "`temp_est'\sym{*}"
		}	
	local speech_did_est = "`speech_did_est' & `temp_est'"
	local speech_did_se = "`speech_did_se' & (`temp_se')"
	local speech_did_obs = "`speech_did_obs' & `temp_N'"
}
file open myfile using "tables/fragments/frag_speech_did.tex", write replace
file write myfile ///
"Treatment Effect `speech_did_est' \\" _n ///
"`speech_did_se' \\" _n
file close myfile

* TABLE A.22
file open myfile using "tables/did_effort.tex", write replace
file write myfile ///
"\begin{table}[htbp]\centering" _n ///
"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" _n ///
"\caption{The Australian Ballot \& Legislator Effort -- Alternative DiD Methods \label{did-effort}}" _n ///
"\begin{tabular}{l*{8}{c}}" _n ///
"\hline\hline" _n ///
"&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}&\multicolumn{1}{c}{(7)}&\multicolumn{1}{c}{(8)}\\" _n ///
"\hline" _n ///
"\multicolumn{8}{l}{} \\[-2ex]" _n ///
"\multicolumn{8}{l}{\textit{Panel A. Private Bill Sponsorship}} \\" _n ///
"\input{tables/fragments/frag_priv_did.tex}" _n ///
"\multicolumn{8}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{8}{l}{\textit{Panel B. Roll-Call Participation Rate}} \\" _n ///
"\input{tables/fragments/frag_rcpart_did.tex}" _n ///
"\multicolumn{8}{l}{} \\[-1.5ex]" _n ///
"\multicolumn{8}{l}{\textit{Panel C. Floor Speeches}} \\" _n ///
"\input{tables/fragments/frag_speech_did.tex}" _n ///
"\multicolumn{8}{l}{} \\[-2ex]" _n ///
"\hline" _n ///
"Method & TWFE & dC-DH & C-S & B-J-S & TWFE & dC-DH & C-S & B-J-S  \\" _n ///
"Unit & District & District & District & District & Member & Member & Member & Member \\" _n ///
"\hline" _n ///
"Panel A Obs. `priv_did_obs' \\" _n ///
"Panel B Obs. `rcpart_did_obs' \\" _n ///
"Panel C Obs. `speech_did_obs' \\" _n ///
"\hline\hline" _n ///
"\multicolumn{9}{l}{\footnotesize Robust standard errors clustered by state are in parentheses. * p $<$ 0.05. The dependent variable for}\\" _n ///
"\multicolumn{9}{l}{\footnotesize Panel A is the logged count of private bills introduced by the member. The dependent variable for Panel B}\\" _n ///
"\multicolumn{9}{l}{\footnotesize is the roll-call participation rate (measured as a proportion). The dependent variable for Panel C is the logged}\\" _n ///
"\multicolumn{9}{l}{\footnotesize count of floor speeches given by the member. No control variables are included in any specification.}\\" _n ///
"\end{tabular}" _n ///
"\end{table}" _n
file close myfile
